From 51ecb4584eab16f7b06985db5f54c64630a41965 Mon Sep 17 00:00:00 2001 From: gcamp Date: Sun, 21 Aug 2011 15:02:27 -0400 Subject: [PATCH] Fix bug when setting both placeholder and text at the same time. Thanks bahrens! --- Demo/GCPlaceholderTextViewDemo.xcodeproj/project.pbxproj | 1 + GCPlaceholderTextView/GCPlaceholderTextView.m | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Demo/GCPlaceholderTextViewDemo.xcodeproj/project.pbxproj b/Demo/GCPlaceholderTextViewDemo.xcodeproj/project.pbxproj index 687ff2a..389ce49 100644 --- a/Demo/GCPlaceholderTextViewDemo.xcodeproj/project.pbxproj +++ b/Demo/GCPlaceholderTextViewDemo.xcodeproj/project.pbxproj @@ -141,6 +141,7 @@ B0B559EC1361DFFA00A8E980 /* Project object */ = { isa = PBXProject; attributes = { + LastUpgradeCheck = 0420; ORGANIZATIONNAME = LittleKiwi; }; buildConfigurationList = B0B559EF1361DFFA00A8E980 /* Build configuration list for PBXProject "GCPlaceholderTextViewDemo" */; diff --git a/GCPlaceholderTextView/GCPlaceholderTextView.m b/GCPlaceholderTextView/GCPlaceholderTextView.m index 0ac3200..f1b2e0d 100644 --- a/GCPlaceholderTextView/GCPlaceholderTextView.m +++ b/GCPlaceholderTextView/GCPlaceholderTextView.m @@ -60,6 +60,13 @@ - (NSString *) text { return text; } +- (void) setText:(NSString *)text { + super.text = text; + + if ([text isEqualToString:self.placeholder]) self.textColor = [UIColor lightGrayColor]; + else self.textColor = self.realTextColor; +} + - (NSString *) realText { return [super text]; }