Skip to content

Commit

Permalink
Merge pull request #24 from epatel/lineheight_fix
Browse files Browse the repository at this point in the history
Small fix to activate line height
  • Loading branch information
honcheng committed Nov 18, 2012
2 parents b3afd63 + 72221bb commit 6869b6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions RTLabelProject/Classes/DemoTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
else
{
RTLabel *rtLabel = [DemoTableViewCell textLabel];
rtLabel.lineSpacing = 20.0;
[rtLabel setText:[rowInfo objectForKey:@"text"]];
CGSize optimumSize = [rtLabel optimumSize];
[rowInfo setObject:[NSNumber numberWithFloat:optimumSize.height+20] forKey:@"cell_height"];
Expand Down Expand Up @@ -141,6 +142,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[cell.rtLabel setDelegate:self];
}
[cell.rtLabel setText:[[self.dataArray objectAtIndex:indexPath.row] objectForKey:@"text"]];
cell.rtLabel.lineSpacing = 20.0;
return cell;
}

Expand Down
11 changes: 6 additions & 5 deletions RTLabelProject/Classes/RTLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ - (void)applyParagraphStyleToText:(CFMutableAttributedStringRef)text attributes:
CGFloat minLineHeight = 0;
CGFloat paragraphSpacing = 0.0;
CGFloat paragraphSpacingBefore = 0.0;
int textAlignment = _textAlignment;
int lineBreakMode = _lineBreakMode;
int lineSpacing = (int)_lineSpacing;
CTTextAlignment textAlignment = (CTTextAlignment)_textAlignment;
CTLineBreakMode lineBreakMode = (CTLineBreakMode)_lineBreakMode;
CGFloat lineSpacing = _lineSpacing;

for (NSUInteger i=0; i<[[attributes allKeys] count]; i++)
{
Expand Down Expand Up @@ -455,8 +455,9 @@ - (void)applyParagraphStyleToText:(CFMutableAttributedStringRef)text attributes:
{ kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), &textAlignment },
{ kCTParagraphStyleSpecifierLineBreakMode, sizeof(CTLineBreakMode), &lineBreakMode },
{ kCTParagraphStyleSpecifierBaseWritingDirection, sizeof(CTWritingDirection), &direction },
{ kCTParagraphStyleSpecifierLineSpacing, sizeof(CGFloat), &lineSpacing }, // leading
{ kCTParagraphStyleSpecifierFirstLineHeadIndent, sizeof(CGFloat), &firstLineIndent },
{ kCTParagraphStyleSpecifierMinimumLineSpacing, sizeof(CGFloat), &lineSpacing }, // leading
{ kCTParagraphStyleSpecifierMaximumLineSpacing, sizeof(CGFloat), &lineSpacing }, // leading
{ kCTParagraphStyleSpecifierFirstLineHeadIndent, sizeof(CGFloat), &firstLineIndent },
{ kCTParagraphStyleSpecifierHeadIndent, sizeof(CGFloat), &headIndent },
{ kCTParagraphStyleSpecifierTailIndent, sizeof(CGFloat), &tailIndent },
{ kCTParagraphStyleSpecifierLineHeightMultiple, sizeof(CGFloat), &lineHeightMultiple },
Expand Down

0 comments on commit 6869b6e

Please sign in to comment.