Skip to content

Commit

Permalink
Merge pull request #2 from bahrens/master
Browse files Browse the repository at this point in the history
Placeholder not always displaying
  • Loading branch information
gcamp committed Aug 21, 2011
2 parents 51ecb45 + b1b3190 commit 5924fe9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions GCPlaceholderTextView/GCPlaceholderTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,20 @@ - (NSString *) text {
return text;
}

- (void) setText:(NSString *)text {
super.text = text;
- (void) setText:(NSString *)text {
if ([text isEqualToString:@""] || text == nil) {
super.text = self.placeholder;
}
else {
super.text = text;
}

if ([text isEqualToString:self.placeholder]) self.textColor = [UIColor lightGrayColor];
else self.textColor = self.realTextColor;
if ([text isEqualToString:self.placeholder]) {
self.textColor = [UIColor lightGrayColor];
}
else {
self.textColor = self.realTextColor;
}
}

- (NSString *) realText {
Expand All @@ -73,14 +82,14 @@ - (NSString *) realText {

- (void) beginEditing:(NSNotification*) notification {
if ([self.realText isEqualToString:self.placeholder]) {
self.text = nil;
super.text = nil;
self.textColor = self.realTextColor;
}
}

- (void) endEditing:(NSNotification*) notification {
if ([self.realText isEqualToString:@""] || self.realText == nil) {
self.text = self.placeholder;
super.text = self.placeholder;
self.textColor = [UIColor lightGrayColor];
}
}
Expand Down

0 comments on commit 5924fe9

Please sign in to comment.