Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
UILabel setLineHeightMultiple:
#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