Created
May 27, 2018 19:21
-
-
Save oalansari82/1af9a76086d916102cc925df93ff41cd to your computer and use it in GitHub Desktop.
Add line spacing to UILabel: https://stackoverflow.com/questions/39158604/how-to-increase-line-spacing-in-uilabel-in-swift
This file contains 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
let attributedString = NSMutableAttributedString(string: "WhatEver text you want") | |
// *** Create instance of `NSMutableParagraphStyle` | |
let paragraphStyle = NSMutableParagraphStyle() | |
// *** set LineSpacing property in points *** | |
paragraphStyle.lineSpacing = 4 // Whatever line spacing you want in points | |
// *** Apply attribute to string *** | |
attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length)) | |
// *** Set Attributed String to your label *** | |
label.attributedText = attributedString |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment