0

I can get either the NSMutableParagraphStyle line spacing working OR the NSMutableAttributedString to be the correct font,color and size, but I can't get them both at the same time.

  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)
Nick
  • 71
  • 2
  • 11
  • 1
    You need to know the difference between NSAttributedString and NSMutableAttributedString. – El Tomato Dec 19 '16 at 02:50
  • even when I added them separately they still overwrote one another, NSAttributed is supposed to be read only so why was I able to change it? Really I'm asking how to chain myMutableString and aboutScrollable.attributedText = NSAttributedString(string: aboutScrollable.text, attributes:attributes) – Nick Dec 19 '16 at 04:17

0 Answers0