Skip to content

Commit

Permalink
Fixed issue when text was non-left-aligned; the smaller rect size cau…
Browse files Browse the repository at this point in the history
…sed problems.
  • Loading branch information
makdad committed Aug 24, 2011
1 parent 46dd339 commit 0abf58b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions TTTAttributedLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ - (void)drawTextInRect:(CGRect)rect {
// Adjust the text to be in the center vertically, if the text size is smaller than the drawing rect
CGSize textSize = CTFramesetterSuggestFrameSizeWithConstraints(self.framesetter, textRange, NULL, textRect.size, &fitRange);
if (textSize.height < textRect.size.height) {
CGFloat yOffset = ((textRect.size.height - textSize.height) / 2);
CGFloat yOffset = (NSInteger)((textRect.size.height - textSize.height) / 2);
textRect.origin = CGPointMake(textRect.origin.x, textRect.origin.y + yOffset);
textRect.size = textSize;
textRect.size = CGSizeMake(textRect.size.width, textRect.size.height - yOffset);
}

// Finally create the text frame based on the path of the rect, draw the frame on the context
Expand Down

0 comments on commit 0abf58b

Please sign in to comment.