Reputation: 491
I have looked at solutions on stack and they have not helped me. The following is my attempt to change the line spacing for the text in my UILabel. Please can someone advise. I see no effect on my line spacing.
let myText = abstractText.text!
let myParagraphStyle = NSMutableParagraphStyle()
myParagraphStyle.lineSpacing = 5
let myNsAttrStringObject = NSAttributedString.init(string: myText, attributes: ["paragraphStyle":myParagraphStyle])
abstractText.attributedText = myNsAttrStringObject
Upvotes: 1
Views: 1245
Reputation: 3939
Your attribute key is not correct in this way, you can use objective-c key NSParagraphStyleAttributeName or swift 4 key NSAttributedStringKey.paragraphStyle:
let myNsAttrStringObject = NSAttributedString.init(string: myText, attributes: [NSParagraphStyleAttributeName: myParagraphStyle])
Upvotes: 3