我是iOS应用程序开发的新手,想了解如何在按钮中使用UIEdgeInsets
属性,请指导我。
我是iOS应用程序开发的新手,想了解如何在按钮中使用UIEdgeInsets
属性,请指导我。
UIEdgeInsets titleInsets = UIEdgeInsetsMake(0.0, 7.0, 0.0, 0.0);
button.titleEdgeInsets = titleInsets;
该代码可为按钮设置内边距,使其更加美观。请注意,保留原有的HTML标签。button.setInset(top: 0.0, left: 7.0, bottom: 0.0, right: 0.0)
extension UIButton {
/**
Creates an edge inset for a button
:param: top CGFLoat
:param: left CGFLoat
:param: bottom CGFLoat
:param: right CGFLoat
*/
func setInset(#top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) {
self.titleEdgeInsets = UIEdgeInsetsMake(top, left, bottom, right)
}
}