【发布时间】:2016-12-26 18:53:29
【问题描述】:
我已经从情节提要创建了一个标签,现在我正在尝试为该标签提供填充。我创建了一个类并尝试了以下两种方法,但没有任何效果。请帮忙。
override func drawTextInRect(rect: CGRect) {
super.drawTextInRect(UIEdgeInsetsInsetRect(rect, UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)))
}
let padding = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)
override func intrinsicContentSize() -> CGSize {
let superContentSize = super.intrinsicContentSize()
let width = superContentSize.width + padding.left + padding.right
let heigth = superContentSize.height + padding.top + padding.bottom
return CGSize(width: width, height: heigth)
}
【问题讨论】: