我很难找到一种方法来添加填充到我的UILabel,它包含一个属性字符串,其中包含文本的背景色。

如图所示,标签的文本没有任何左侧填充-我需要能够在左侧和右侧添加一些填充。下面是我当前的代码:
var attributedString = NSMutableAttributedString(string: "\(blueHighlightedText)")
attributedString.addAttribute(NSBackgroundColorAttributeName, value: UIColor(red: 0.369, green: 0.718, blue: 0.882, alpha: 0.83), range: NSMakeRange(0, blueHighlightedText.bridgeToObjectiveC().length))
attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, blueHighlightedText.bridgeToObjectiveC().length))
attributedString.addAttribute(NSKernAttributeName, value: -0.35, range: NSMakeRange(0, blueHighlightedText.bridgeToObjectiveC().length))
attributedText = NSAttributedString(attributedString: attributedString)我怎么才能给这个添加填充呢?
发布于 2014-07-23 05:39:40
设置标签的contentEdgeInsets,或将标签作为子视图添加到彩色视图和位置。
https://stackoverflow.com/questions/24898234
复制相似问题