From e68bea3407b7ee729e86c2f1a5911577d37b13ba Mon Sep 17 00:00:00 2001 From: Stas Zhukovskiy Date: Mon, 30 Sep 2013 09:36:17 +0400 Subject: [PATCH 1/2] fixed deprecated call in drawRect: --- SAMTextView/SAMTextView.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/SAMTextView/SAMTextView.m b/SAMTextView/SAMTextView.m index 89def06..45e8c12 100644 --- a/SAMTextView/SAMTextView.m +++ b/SAMTextView/SAMTextView.m @@ -8,6 +8,8 @@ #import "SAMTextView.h" +#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) + @implementation SAMTextView #pragma mark - Accessors @@ -96,7 +98,17 @@ - (void)drawRect:(CGRect)rect { // Draw the text [self.placeholderTextColor set]; - [self.placeholder drawInRect:rect withFont:font lineBreakMode:NSLineBreakByTruncatingTail alignment:self.textAlignment]; + if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")){ + NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; + paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail; + paragraphStyle.alignment = self.textAlignment; + NSDictionary *attributes = @{NSFontAttributeName : self.font, + NSParagraphStyleAttributeName : paragraphStyle}; + [_placeholder drawInRect:rect withAttributes:attributes]; + } + else { + [self.placeholder drawInRect:rect withFont:font lineBreakMode:NSLineBreakByTruncatingTail alignment:self.textAlignment]; + } } } From 5d08f2c9a22bf828319207a63700b915340d34ff Mon Sep 17 00:00:00 2001 From: Stas Zhukovskiy Date: Tue, 3 Dec 2013 02:36:50 +0400 Subject: [PATCH 2/2] changed the if clause to respondsToSelector --- SAMTextView/SAMTextView.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SAMTextView/SAMTextView.m b/SAMTextView/SAMTextView.m index 45e8c12..d4d87ae 100644 --- a/SAMTextView/SAMTextView.m +++ b/SAMTextView/SAMTextView.m @@ -8,8 +8,6 @@ #import "SAMTextView.h" -#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) - @implementation SAMTextView #pragma mark - Accessors @@ -98,7 +96,7 @@ - (void)drawRect:(CGRect)rect { // Draw the text [self.placeholderTextColor set]; - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")){ + if ([_placeholder respondsToSelector:@selector(drawInRect:withAttributes:)]){ NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail; paragraphStyle.alignment = self.textAlignment;