我在xib文件上有一个UILabel,我想增加文本的行间距。NSMutableParagraphStyle不叫
我试着写,但下面的代码只调用文本对齐方式,行间距保持不变。为什么不调用“paragraphStyle.lineSpacing”?
class PlaySheetCellLeft: UITableViewCell {
@IBOutlet var LBLTitle:UILabel!
var message:[String:Any]? {
didSet{
guard let msg = self.message else { return }
self.LBLTitle.text = title
}
override func awakeFromNib() {
super.awakeFromNib()
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 10
let attrString = NSMutableAttributedString()
attrString.addAttribute(NSParagraphStyleAttributeName, value:paragraphStyle, range:NSMakeRange(0, attrString.length))
LBLTitle.attributedText = attrString
LBLTitle.textAlignment = NSTextAlignment.center
}
}
你的程序有4个''''6'}',缩进很容易让人误解。这实际上是你的班级的样子吗? – Ssswift