Skip to content

Instantly share code, notes, and snippets.

@ishida
Last active September 28, 2021 17:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishida/d76dce6e30eaf0a77dbb to your computer and use it in GitHub Desktop.
Save ishida/d76dce6e30eaf0a77dbb to your computer and use it in GitHub Desktop.
Update line height of UILabel in storyboard
@implementation UILabel (Extensions)
...
- (void)setLineHeight:(float)lineHeight
{
NSMutableParagraphStyle *paragrahStyle = [[NSMutableParagraphStyle alloc] init];
paragrahStyle.minimumLineHeight = lineHeight;
paragrahStyle.maximumLineHeight = lineHeight;
NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc]
initWithString:self.text];
[attributedText addAttribute:NSParagraphStyleAttributeName
value:paragrahStyle
range:NSMakeRange(0, attributedText.length)];
self.text = nil;
self.attributedText = attributedText;
}
...
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment