aboutsummaryrefslogtreecommitdiff
path: root/iPhone
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2014-08-20 18:00:16 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2014-08-20 18:00:16 +0000
commit9cb4be9a147d217254a82a8602182fa3bcc2264e (patch)
treeca3ffcaa7b9e6e540487b262a488244c8057f7e3 /iPhone
parent24483183e727acc8daf490ea9f288ee7546991a6 (diff)
Fix compilation against iOS 7 deployment target.
DELTA=35 (34 added, 0 deleted, 1 changed) DELTA_BY_EXTENSION=m=35
Diffstat (limited to 'iPhone')
-rwxr-xr-xiPhone/GTMFadeTruncatingLabel.m36
1 files changed, 35 insertions, 1 deletions
diff --git a/iPhone/GTMFadeTruncatingLabel.m b/iPhone/GTMFadeTruncatingLabel.m
index 0a5d0bb..7cdf0cb 100755
--- a/iPhone/GTMFadeTruncatingLabel.m
+++ b/iPhone/GTMFadeTruncatingLabel.m
@@ -49,7 +49,12 @@
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
+ // |sizeWithFont:| is deprecated in iOS 7, replaced by |sizeWithAttributes:|
CGSize size = [self.text sizeWithFont:self.font];
+#else
+ CGSize size = [self.text sizeWithAttributes:@{NSFontAttributeName:self.font}];
+#endif
if (size.width > requestedRect.size.width) {
UIImage* image = [[self class]
getLinearGradient:requestedRect
@@ -62,18 +67,47 @@
CGContextSetFillColorWithColor(context, self.shadowColor.CGColor);
CGRect shadowRect = CGRectOffset(requestedRect, self.shadowOffset.width,
self.shadowOffset.height);
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
+ // |drawInRect:withFont:lineBreakMode:alignment:| is deprecated in iOS 7,
+ // replaced by |drawInRect:withAttributes:|
[self.text drawInRect:shadowRect
withFont:self.font
lineBreakMode:self.lineBreakMode
alignment:self.textAlignment];
+#else
+ NSMutableParagraphStyle* textStyle =
+ [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
+ textStyle.lineBreakMode = self.lineBreakMode;
+ textStyle.alignment = self.textAlignment;
+ NSDictionary* attributes = @{
+ NSFontAttributeName:self.font,
+ NSParagraphStyleAttributeName:textStyle,
+ };
+ [self.text drawInRect:shadowRect
+ withAttributes:attributes];
+#endif
}
CGContextSetFillColorWithColor(context, self.textColor.CGColor);
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
+ // |drawInRect:withFont:lineBreakMode:alignment:| is deprecated in iOS 7,
+ // replaced by |drawInRect:withAttributes:|
[self.text drawInRect:requestedRect
withFont:self.font
lineBreakMode:self.lineBreakMode
alignment:self.textAlignment];
-
+#else
+ NSMutableParagraphStyle* textStyle =
+ [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
+ textStyle.lineBreakMode = self.lineBreakMode;
+ textStyle.alignment = self.textAlignment;
+ NSDictionary* attributes = @{
+ NSFontAttributeName:self.font,
+ NSParagraphStyleAttributeName:textStyle,
+ };
+ [self.text drawInRect:requestedRect
+ withAttributes:attributes];
+#endif
CGContextRestoreGState(context);
}