Last active
September 28, 2021 17:09
-
-
Save ishida/d76dce6e30eaf0a77dbb to your computer and use it in GitHub Desktop.
Update line height of UILabel in storyboard
This file contains hidden or 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
@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