Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

How to control the line spacing in UILabel

// Usage: setTextWithLineSpacing(myEpicUILabel,text:"Hello",lineSpacing:20)
func setTextWithLineSpacing(label:UILabel,text:String,lineSpacing:CGFloat)
{
    let paragraphStyle = NSMutableParagraphStyle()
    paragraphStyle.lineSpacing = lineSpacing

    let attrString = NSMutableAttributedString(string: text)
    attrString.addAttribute(NSAttributedString.Key.paragraphStyle, value:paragraphStyle, range:NSMakeRange(0, attrString.length))

    label.attributedText = attrString
}
Comment

PREVIOUS NEXT
Code Example
Swift :: how to add social media icons in swiftui 
Swift :: swift 5 func to increase number every time call 
Swift :: how to select but not focus textfield swift 
Swift :: swift navigation bar title font 
Swift :: pop the view controller xcode 
Swift :: swift bring something to front of view 
Swift :: swift do catch 
Swift :: how to get rid of excess space in swift 
Swift :: Save class in userdefaults ios swift 
Swift :: swift dispatch after 
Swift :: swift clear user defaults 
Swift :: print an array in swift 
Swift :: how to bold text swiftui 
Swift :: swift dismiss keyboard on return 
Swift :: tuple swift 
Swift :: struct vs enum swift 
Swift :: swift add programmatically constraint to view 
Swift :: uitextview placeholder uikit ios 
Swift :: swift 5 get first character of string 
Swift :: swift convert string to int 
Swift :: turning an arrya into a set swift 
Swift :: ios UIButton change image 
Swift :: swift check if regex is in string 
Swift :: swift subtract dates 
Swift :: two variable sum 
Swift :: Swift Double 
Swift :: Swift continue with while loop 
Swift :: async await apis for ios 13 
Swift :: swift hmac256 
Swift :: swiftui button only text tappable 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =