I am a little puzzled why the following is not working, button_ONE does a nice fade, but pressing button_TWO just snaps the color to black with no fade.
// FADES OUT OVER 1.5 Secs
- (IBAction)button_ONE:(id)sender {
NSLog(@"FADE ALPHA");
[textField_TOP_01 setAlpha:1.0];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[textField_TOP_01 setAlpha:0.0];
[UIView commitAnimations];
}
.
// IMMEDIATELY CHANGES TO BLACK
- (IBAction)button_TWO:(id)sender {
NSLog(@"FADE COLOR");
[textField_TOP_02 setTextColor:[UIColor redColor]];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[textField_TOP_02 setTextColor:[UIColor blackColor]];
[UIView commitAnimations];
}
Also this is using a subclass of UIViewController, I am also a little puzzled as to what UIView is refering / how its working.
many thanks
Gary
The textColor property of a UILabel is not an animatable property, so it’s changes are not done as part of the animation.
The animation related methods on UIView are class methods rather than instance methods, so you call them on the class directly. Check out the documentation on ‘method type identifiers’ at http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/.