Created
December 11, 2018 12:14
-
-
Save fabiogiolito/f63226c2a3d10026ef5d7992df43ed1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UILabel { | |
func setLineSpacing(lineSpacing: CGFloat) { | |
let text = self.text | |
if let text = text { | |
let attributeString = NSMutableAttributedString(string: text) | |
let style = NSMutableParagraphStyle() | |
style.lineSpacing = lineSpacing | |
style.alignment = self.textAlignment | |
attributeString.addAttribute(NSAttributedString.Key.paragraphStyle, value: style, range: NSMakeRange(0, text.count)) | |
self.attributedText = attributeString | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment