From f3f9e02c47976092f6bb9e3a9e7f49a876ab20c0 Mon Sep 17 00:00:00 2001 From: paulwalton Date: Thu, 26 Sep 2013 12:33:01 +0100 Subject: [PATCH] Updates iOS7 Compatibility --- NoticeView/WBNoticeView/UILabel+WBExtensions.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NoticeView/WBNoticeView/UILabel+WBExtensions.m b/NoticeView/WBNoticeView/UILabel+WBExtensions.m index d8d60b9..3440e46 100644 --- a/NoticeView/WBNoticeView/UILabel+WBExtensions.m +++ b/NoticeView/WBNoticeView/UILabel+WBExtensions.m @@ -37,7 +37,9 @@ - (NSArray *)lines NSRange rTest = NSMakeRange(rRemainingText.location, rWhitespace.location - rRemainingText.location); NSString *textTest = [self.text substringWithRange:rTest]; - CGSize sizeTest = [textTest sizeWithFont:self.font forWidth:1024.0 lineBreakMode:NSLineBreakByWordWrapping]; + NSAttributedString *attributedText =[[NSAttributedString alloc] initWithString:textTest attributes:@{NSFontAttributeName: self.font}]; + CGRect rect = [attributedText boundingRectWithSize:(CGSize){1024.0, CGFLOAT_MAX}options:NSStringDrawingUsesLineFragmentOrigin context:nil]; + CGSize sizeTest = rect.size; if (sizeTest.width > self.bounds.size.width) { [lines addObject:[currentLine stringByTrimmingCharactersInSet:wordSeparators]];