I want to be able to create an animation that is started using a UISwitch. I currently have this code to hide some UI elements when the switch is on:
-(IBAction)displayStartingAddress:(id)sender{
NSLog(@"starting displayStartingAddress");
if (enterStartingAddress.hidden==YES) {
enterStartingAddress.hidden=NO;
startingAddress.hidden=NO;
}else{
enterStartingAddress.hidden=YES;
startingAddress.hidden=YES;
}
}
And I want the switch to cause an animation to the UI elements to move them down when the “enterStartingAddress” and “startingAddress” is shown.
I am very new to iOS programming and Objective-C so any help would be appreciated. Thanks.
If you set the interface elements to hidden right away, no animation will be performed because it will be hidden while it’s animating. What you want to do is to animate the
alphaproperty. That is the visibility of the object. Here is an example of animating the frame and the alpha a bit: