Skip to content

Instantly share code, notes, and snippets.

@tdksk
Created November 27, 2014 13:29
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 tdksk/d547fa69820bc4b7860a to your computer and use it in GitHub Desktop.
Save tdksk/d547fa69820bc4b7860a to your computer and use it in GitHub Desktop.
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