How to control the line spacing in UILabel How to control the line spacing in UILabel xcode xcode

How to control the line spacing in UILabel


In Xcode 6 you can do this in the storyboard:

enter image description here


I thought about adding something new to this answer, so I don't feel as bad... Here is a Swift answer:

import Cocoalet paragraphStyle = NSMutableParagraphStyle()paragraphStyle.lineSpacing = 40let attrString = NSMutableAttributedString(string: "Swift Answer")attrString.addAttribute(.paragraphStyle, value:paragraphStyle, range:NSMakeRange(0, attrString.length))var tableViewCell = NSTableCellView()tableViewCell.textField.attributedStringValue = attrString

"Short answer: you can't. To change the spacing between lines of text, you will have to subclass UILabel and roll your own drawTextInRect, or create multiple labels."

See: Set UILabel line spacing


This is a really old answer, and other have already addded the new and better way to handle this.. Please see the up to date answers provided below.


Starting from iOS 6 you can set an attributed string to the UILabel. Check the following :

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:label.text];NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];paragraphStyle.lineSpacing = spacing;[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, label.text.length)];label.attributedText = attributedString;