From 9b8ce4979d2ff5ad3e95cc0e3db72de653158cfe Mon Sep 17 00:00:00 2001 From: Niyazi Date: Tue, 1 Apr 2014 16:47:07 +0300 Subject: [PATCH 1/3] Deprecated methods updated Deprecated sizeWithFont: methods updated for iOS SDK 7.0 and above --- PopoverView/PopoverView.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) mode change 100644 => 100755 PopoverView/PopoverView.m diff --git a/PopoverView/PopoverView.m b/PopoverView/PopoverView.m old mode 100644 new mode 100755 index 1bf43b5..503aa1e --- a/PopoverView/PopoverView.m +++ b/PopoverView/PopoverView.m @@ -162,6 +162,12 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withText:(NSString *)te CGSize screenSize = [self screenSize]; CGSize textSize = [text sizeWithFont:font constrainedToSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) lineBreakMode:UILineBreakModeWordWrap]; + CGRect textRect = [text boundingRectWithSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) + options:NSStringDrawingUsesLineFragmentOrigin + attributes:@{NSFontAttributeName:font} + context:nil]; + + CGSize textSize = textRect.size; UILabel *textView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)]; textView.backgroundColor = [UIColor clearColor]; @@ -181,6 +187,12 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t CGSize screenSize = [self screenSize]; CGSize textSize = [text sizeWithFont:font constrainedToSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) lineBreakMode:UILineBreakModeWordWrap]; + CGRect textRect = [text boundingRectWithSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) + options:NSStringDrawingUsesLineFragmentOrigin + attributes:@{NSFontAttributeName:font} + context:nil]; + + CGSize textSize = textRect.size; UILabel *textView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)]; textView.backgroundColor = [UIColor clearColor]; @@ -270,6 +282,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t //Create a label for the title text. CGSize titleSize = [title sizeWithFont:kTitleFont]; + CGSize titleSize = [title sizeWithAttributes:@{NSFontAttributeName:kTitleFont}]; UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.f, 0.f, titleSize.width, titleSize.height)]; titleLabel.backgroundColor = [UIColor clearColor]; titleLabel.font = kTitleFont; @@ -357,6 +370,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withStringArray:(NSArra for (NSString *string in stringArray) { CGSize textSize = [string sizeWithFont:font]; + CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:font}]; UIButton *textButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)]; textButton.backgroundColor = [UIColor clearColor]; textButton.titleLabel.font = font; @@ -382,6 +396,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t for (NSString *string in stringArray) { CGSize textSize = [string sizeWithFont:font]; + CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:kTitleFont}]; UIButton *textButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)]; textButton.backgroundColor = [UIColor clearColor]; textButton.titleLabel.font = font; @@ -429,6 +444,7 @@ - (NSMutableArray*) makeTempViewsWithStrings:(NSArray *)stringArray andImages:(N //First we build a label for the text to set in. CGSize textSize = [string sizeWithFont:font]; + CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:font}]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)]; label.backgroundColor = [UIColor clearColor]; label.font = font; From 1ae37b4f31c1eaa8a161e46b6e3310b00318031d Mon Sep 17 00:00:00 2001 From: Niyazi Date: Tue, 1 Apr 2014 16:47:29 +0300 Subject: [PATCH 2/3] Deprecated methods updated Deprecated sizeWithFont: methods updated for iOS SDK 7.0 and above --- PopoverView/PopoverView.m | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/PopoverView/PopoverView.m b/PopoverView/PopoverView.m index 503aa1e..2bb644d 100755 --- a/PopoverView/PopoverView.m +++ b/PopoverView/PopoverView.m @@ -159,9 +159,8 @@ - (CGSize) screenSize - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withText:(NSString *)text { UIFont *font = kTextFont; - + UIColor *patternColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navBarPattern.png"]]; CGSize screenSize = [self screenSize]; - CGSize textSize = [text sizeWithFont:font constrainedToSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) lineBreakMode:UILineBreakModeWordWrap]; CGRect textRect = [text boundingRectWithSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:font} @@ -175,7 +174,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withText:(NSString *)te [textView setNumberOfLines:0]; //This is so the label word wraps instead of cutting off the text textView.font = font; textView.textAlignment = kTextAlignment; - textView.textColor = kTextColor; + textView.textColor = patternColor; textView.text = text; [self showAtPoint:point inView:view withViewArray:[NSArray arrayWithObject:[textView AUTORELEASE]]]; @@ -186,7 +185,6 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t UIFont *font = kTextFont; CGSize screenSize = [self screenSize]; - CGSize textSize = [text sizeWithFont:font constrainedToSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) lineBreakMode:UILineBreakModeWordWrap]; CGRect textRect = [text boundingRectWithSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:font} @@ -281,8 +279,8 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t UIView *container = [[UIView alloc] initWithFrame:CGRectZero]; //Create a label for the title text. - CGSize titleSize = [title sizeWithFont:kTitleFont]; CGSize titleSize = [title sizeWithAttributes:@{NSFontAttributeName:kTitleFont}]; + //CGSize size = [string sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17.0f]}]; UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.f, 0.f, titleSize.width, titleSize.height)]; titleLabel.backgroundColor = [UIColor clearColor]; titleLabel.font = kTitleFont; @@ -369,7 +367,6 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withStringArray:(NSArra UIFont *font = kTextFont; for (NSString *string in stringArray) { - CGSize textSize = [string sizeWithFont:font]; CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:font}]; UIButton *textButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)]; textButton.backgroundColor = [UIColor clearColor]; @@ -395,7 +392,6 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t UIFont *font = kTextFont; for (NSString *string in stringArray) { - CGSize textSize = [string sizeWithFont:font]; CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:kTitleFont}]; UIButton *textButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)]; textButton.backgroundColor = [UIColor clearColor]; @@ -443,7 +439,6 @@ - (NSMutableArray*) makeTempViewsWithStrings:(NSArray *)stringArray andImages:(N NSString *string = [stringArray objectAtIndex:i]; //First we build a label for the text to set in. - CGSize textSize = [string sizeWithFont:font]; CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:font}]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)]; label.backgroundColor = [UIColor clearColor]; From 2d0259b7cb5e808f67e7aa77834f84d615323048 Mon Sep 17 00:00:00 2001 From: Niyazi Date: Tue, 1 Apr 2014 16:52:04 +0300 Subject: [PATCH 3/3] Deprecated methods updated Deprecated sizeWithFont: methods updated for iOS SDK 7.0 and above --- PopoverView/PopoverView.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PopoverView/PopoverView.m b/PopoverView/PopoverView.m index 2bb644d..7a48f57 100755 --- a/PopoverView/PopoverView.m +++ b/PopoverView/PopoverView.m @@ -159,7 +159,6 @@ - (CGSize) screenSize - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withText:(NSString *)text { UIFont *font = kTextFont; - UIColor *patternColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navBarPattern.png"]]; CGSize screenSize = [self screenSize]; CGRect textRect = [text boundingRectWithSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) options:NSStringDrawingUsesLineFragmentOrigin @@ -174,7 +173,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withText:(NSString *)te [textView setNumberOfLines:0]; //This is so the label word wraps instead of cutting off the text textView.font = font; textView.textAlignment = kTextAlignment; - textView.textColor = patternColor; + textView.textColor = kTextColor; textView.text = text; [self showAtPoint:point inView:view withViewArray:[NSArray arrayWithObject:[textView AUTORELEASE]]];