contentEdgeInsets
。这些是围绕按钮所有内容的矩形的最外边缘的边距。myButton.contentEdgeInsets = UIEdgeInsetsMake(5,5,5,5);
UIButton
的titleEdgeInsets
属性 myButton.titleEdgeInsets = UIEdgeInsets(5, 5, 5, 5);
根据需要调整插入值!有关titleEdgeInsets
的更多详细信息,请参阅Apple Docs
button.configuration.contentInset = UIEdgeInsets(top: 2, left: 4, bottom: 2, right: 4)
对于旧版本:
button.contentEdgeInsets = UIEdgeInsets(top: 2, left: 4, bottom: 2, right: 4)