Skip to content

Commit

Permalink
[Issue #190] Fixing line break mode for number of lines <> 1 in iOS 6
Browse files Browse the repository at this point in the history
Signed-off-by: Mattt Thompson <m@mattt.me>
  • Loading branch information
tsafrir authored and mattt committed Mar 19, 2013
1 parent 4ca7b80 commit 25d8635
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion TTTAttributedLabel/TTTAttributedLabel.m
Expand Up @@ -84,14 +84,20 @@ static inline NSTextCheckingType NSTextCheckingTypeFromUIDataDetectorType(UIData

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = label.textAlignment;
paragraphStyle.lineBreakMode = label.lineBreakMode;
paragraphStyle.lineSpacing = label.leading;
paragraphStyle.lineHeightMultiple = label.lineHeightMultiple;
paragraphStyle.firstLineHeadIndent = label.firstLineIndent;
paragraphStyle.paragraphSpacingBefore = label.textInsets.top;
paragraphStyle.paragraphSpacing = label.textInsets.bottom;
paragraphStyle.headIndent = label.textInsets.left;
paragraphStyle.tailIndent = label.textInsets.right;

if (label.numberOfLines == 1) {
paragraphStyle.lineBreakMode = label.lineBreakMode;
} else {
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
}

[mutableAttributes setObject:paragraphStyle forKey:(NSString *)kCTParagraphStyleAttributeName];
} else {
CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)label.font.fontName, label.font.pointSize, NULL);
Expand Down

0 comments on commit 25d8635

Please sign in to comment.