Reducing Line Spacing of Text in SwiftUI

EDIT: Unfortunately this stopped working in Xcode 15 as the function is now marked internal and there is no other option available. Damn Apple! Based on tadelv comment. lineSpacing does not accept negative values, but you have a hidden API _lineHeightMultiple that works. It says it’s deprecated but the suggested one does not exist! var … Read more

Core Text – NSAttributedString line height done right?

Objective-C NSInteger strLength = [myString length]; NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; [style setLineSpacing:24]; [attString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, strLength)]; Swift 5 let strLength = myString.length() var style = NSMutableParagraphStyle() style.lineSpacing = 24 attString.addAttribute(.paragraphStyle, value: style, range: NSRange(location: 0, length: strLength))

Set UILabel line spacing

Edit: Evidently NSAttributedString will do it, on iOS 6 and later. Instead of using an NSString to set the label’s text, create an NSAttributedString, set attributes on it, then set it as the .attributedText on the label. The code you want will be something like this: NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString:@”Sample text”]; NSMutableParagraphStyle *style … Read more

How to Increase Line spacing in UILabel in Swift

Programatically add LineSpacing to your UILabel using following snippet. Earlier Swift version let attributedString = NSMutableAttributedString(string: “Your text”) // *** Create instance of `NSMutableParagraphStyle` let paragraphStyle = NSMutableParagraphStyle() // *** set LineSpacing property in points *** paragraphStyle.lineSpacing = 2 // Whatever line spacing you want in points // *** Apply attribute to string *** attributedString.addAttribute(NSParagraphStyleAttributeName, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)