无法同时更改Paragraph属性和String Attributes

时间:2016-12-19 02:36:34

标签: swift nsmutableattributedstring nsparagraphstyle

我可以使NSMutableParagraphStyle行间距工作或NSMutableAttributedString为正确的字体,颜色和大小,但我无法同时获取它们。

  let style = NSMutableParagraphStyle()
style.lineSpacing = 5
let attributes = [NSParagraphStyleAttributeName : style]
aboutScrollable.attributedText = NSAttributedString(string: aboutScrollable.text, attributes:attributes)



let myString:NSString = aboutScrollable.text as NSString
var myMutableString = NSMutableAttributedString()

myMutableString = NSMutableAttributedString(string: myString as String, attributes: [NSFontAttributeName:UIFont(name: "Geomanist-regular", size: 12.0)!])

myMutableString.addAttribute(NSForegroundColorAttributeName, value: UIColor(red: 30/255, green: 30/255, blue: 30/255, alpha: 1), range: NSRange(location: 0,length: aboutScrollable.text.characters.count))


// set label Attribute
aboutScrollable.attributedText = myMutableString; NSAttributedString(string: aboutScrollable.text, attributes:attributes)

0 个答案:

没有答案