Created
November 27, 2014 13:29
-
-
Save tdksk/d547fa69820bc4b7860a to your computer and use it in GitHub Desktop.
UILabel setLineHeightMultiple:
This file contains 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
#import "UILabel+TDKUtil.h" | |
@implementation UILabel (TDKUtil) | |
- (void)setLineHeightMultiple:(CGFloat)lineHeightMultiple | |
{ | |
NSMutableAttributedString *attributedString = [self.attributedText mutableCopy]; | |
NSMutableParagraphStyle *paragrahStyle = [NSMutableParagraphStyle new]; | |
paragrahStyle.lineHeightMultiple = lineHeightMultiple; | |
paragrahStyle.lineBreakMode = NSLineBreakByTruncatingTail; | |
[attributedString addAttribute:NSParagraphStyleAttributeName | |
value:paragrahStyle | |
range:NSMakeRange(0, attributedString.length)]; | |
[self setAttributedText:attributedString]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment