Skip to content

Commit

Permalink
Added fix for Sumi-Interactive#85
Browse files Browse the repository at this point in the history
  • Loading branch information
ebothmann committed Feb 21, 2015
1 parent 60fac3b commit 4aa4089
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions SIAlertView/SIAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -982,35 +982,26 @@ - (CGFloat)heightForTitleLabel

- (CGFloat)heightForMessageLabel
{
CGFloat minHeight = MESSAGE_MIN_LINE_COUNT * self.messageLabel.font.lineHeight;
if (self.messageLabel) {
CGFloat maxHeight = MESSAGE_MAX_LINE_COUNT * self.messageLabel.font.lineHeight;

#ifdef __IPHONE_7_0
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineBreakMode = self.messageLabel.lineBreakMode;

NSDictionary *attributes = @{NSFontAttributeName:self.messageLabel.font,
NSParagraphStyleAttributeName: paragraphStyle.copy};

// NSString class method: boundingRectWithSize:options:attributes:context is
// available only on ios7.0 sdk.
CGRect rect = [self.titleLabel.text boundingRectWithSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, maxHeight)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:attributes
context:nil];

return MAX(minHeight, ceil(rect.size.height));
#else
CGSize size = [self.message sizeWithFont:self.messageLabel.font
constrainedToSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, maxHeight)
lineBreakMode:self.messageLabel.lineBreakMode];

return MAX(minHeight, size.height);
#endif
}

return minHeight;
CGFloat minHeight = MESSAGE_MIN_LINE_COUNT * self.messageLabel.font.lineHeight;
if (self.messageLabel) {
CGFloat maxHeight = MESSAGE_MAX_LINE_COUNT * self.messageLabel.font.lineHeight;

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0
CGRect rect = [self.message boundingRectWithSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, maxHeight)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:self.messageLabel.font}
context:nil];
return MAX(minHeight, ceil(rect.size.height));
#else
CGSize size = [self.message sizeWithFont:self.messageLabel.font
constrainedToSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, maxHeight)
lineBreakMode:self.messageLabel.lineBreakMode];

return MAX(minHeight, size.height);
#endif
}

return minHeight;
}

#pragma mark - Setup
Expand Down

0 comments on commit 4aa4089

Please sign in to comment.