I have a UIButton
that is gray when the user enters a viewController. There is also a UITextView
. If the user enters text into the UITextView
, then the button should turn red, but if the text view is blank, the the button is gray. If was thinking of doing something like bellow, which does change the color to red if the user enters text, but if the user deletes the text, it stays red instead of going back to gray. Here is the code I am using:
- (void)textViewDidChange:(UITextView *)textView {
if (self.textView.text.length == 0) {
self.navigationItem.rightBarButtonItem.tintColor = [UIColor colorWithRed:193/255.5 green:193/255.0 blue:193/255.0 alpha:1.0];
}else{
self.navigationItem.rightBarButtonItem.tintColor = [UIColor redColor];
}
if (self.titleView.text.length == 0) {
self.navigationItem.rightBarButtonItem.tintColor = [UIColor colorWithRed:193/255.5 green:193/255.0 blue:193/255.0 alpha:1.0];
}else{
self.navigationItem.rightBarButtonItem.tintColor = [UIColor redColor];
}
NSLog(@"Typing has stopped");
}