使用 Swift 向 UILabel 添加顶部和底部填充
Add top and bottom padding to UILabel using Swift
如何在 UILabel
中的内容的顶部和底部添加填充?
我试图通过 NSAttributedString
文本找到实现此目的的方法,但似乎无法找到仅将边距应用到顶部和底部的方法。
在 swift 中执行此操作:-
class Label: UILabel {
override func drawTextInRect(rect: CGRect) {
super.drawTextInRect(UIEdgeInsetsInsetRect(rect, UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)))
}
}
如何在 UILabel
中的内容的顶部和底部添加填充?
我试图通过 NSAttributedString
文本找到实现此目的的方法,但似乎无法找到仅将边距应用到顶部和底部的方法。
在 swift 中执行此操作:-
class Label: UILabel {
override func drawTextInRect(rect: CGRect) {
super.drawTextInRect(UIEdgeInsetsInsetRect(rect, UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)))
}
}