From d592363206a93b924edb50a8736b6f7e1088d5f9 Mon Sep 17 00:00:00 2001 From: Ronak Date: Tue, 24 Dec 2013 15:02:54 +0530 Subject: [PATCH 1/2] Assigning null to NSFontAttributeName attributes will crash app. Assign font only if present --- SAMTextView/SAMTextView.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SAMTextView/SAMTextView.m b/SAMTextView/SAMTextView.m index 7c7801c..282fbbf 100644 --- a/SAMTextView/SAMTextView.m +++ b/SAMTextView/SAMTextView.m @@ -41,7 +41,9 @@ - (void)setPlaceholder:(NSString *)string { if ([self isFirstResponder] && self.typingAttributes) { [attributes addEntriesFromDictionary:self.typingAttributes]; } else { - attributes[NSFontAttributeName] = self.font; + if (self.font) { + attributes[NSFontAttributeName] = self.font; + } attributes[NSForegroundColorAttributeName] = [UIColor colorWithWhite:0.702f alpha:1.0f]; if (self.textAlignment != NSTextAlignmentLeft) { From 61ef86656a2e0a26b5378b63feb6ffa7b48545f6 Mon Sep 17 00:00:00 2001 From: Ronak Date: Tue, 24 Dec 2013 15:06:55 +0530 Subject: [PATCH 2/2] for iOS 6, remove extra top padding from placeholder and use contentInset top for top padding --- SAMTextView/SAMTextView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SAMTextView/SAMTextView.m b/SAMTextView/SAMTextView.m index 282fbbf..56f2672 100644 --- a/SAMTextView/SAMTextView.m +++ b/SAMTextView/SAMTextView.m @@ -141,7 +141,7 @@ - (CGRect)placeholderRectForBounds:(CGRect)bounds { if (self.contentInset.left == 0.0f) { rect.origin.x += 8.0f; } - rect.origin.y += 8.0f; + rect.origin.y += self.contentInset.top; } return rect;