From d4ce2bd2270f3cabc7ec0d9d3944e5b40060f77f Mon Sep 17 00:00:00 2001 From: lunarbase Date: Wed, 5 Mar 2014 02:54:00 +0000 Subject: [PATCH] Update OLGhostAlertView.m Your code was giving warning about deprecation on iOS 7. This solved the problem for me. --- OLGhostAlertView.m | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/OLGhostAlertView.m b/OLGhostAlertView.m index 8f52d4f..162cf00 100644 --- a/OLGhostAlertView.m +++ b/OLGhostAlertView.m @@ -201,6 +201,19 @@ - (void)hide #pragma mark - View layout +- (CGSize)calculateLabelSizeForText:(NSString *)text usingFont:(UIFont *)font restrictedToSize:(CGSize)constrainedSize { + + UILabel *gettingSizeLabel = [[UILabel alloc] init]; + gettingSizeLabel.font = font; + gettingSizeLabel.text = text; + gettingSizeLabel.numberOfLines = 0; + CGSize maximumLabelSize = CGSizeMake(310, 9999); + + return [gettingSizeLabel sizeThatFits:maximumLabelSize]; + +} + + - (void)layoutSubviews { CGFloat maxWidth = 0; @@ -222,12 +235,17 @@ - (void)layoutSubviews constrainedSize.width = maxWidth; constrainedSize.height = MAXFLOAT; - CGSize titleSize = [self.title sizeWithFont:[UIFont boldSystemFontOfSize:TITLE_FONT_SIZE] constrainedToSize:constrainedSize]; + CGSize titleSize = [self calculateLabelSizeForText:self.title + usingFont:[UIFont boldSystemFontOfSize:TITLE_FONT_SIZE] + restrictedToSize:constrainedSize]; + CGSize messageSize = CGSizeZero; if (self.message) { - messageSize = [self.message sizeWithFont:[UIFont systemFontOfSize:MESSAGE_FONT_SIZE] constrainedToSize:constrainedSize]; - + messageSize = [self calculateLabelSizeForText:self.message + usingFont:[UIFont systemFontOfSize:MESSAGE_FONT_SIZE] + restrictedToSize:constrainedSize]; + totalHeight = titleSize.height + messageSize.height + floorf(VERTICAL_PADDING * 2.5); } else {