Reputation: 1079
Hai all,
in my iphone application, when i click a UIButton it will show a UIDatePicker (using setVisible:YES) ,is there any way to animate the DatePicker appearance,(now when the user taps it will suddenly appear in the UI)
thanks in advance
Upvotes: 0
Views: 1457
Reputation: 696
Yes , it is possible to have an animation when you call your picker to set visible.
Initially your picker is hidden. When UIButton is pressed You just call below method (animatePicker). In below method there is just hidden set to false for pickerview but with CAanimation.
-(void)animatePicker
{
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
// Set the type and if appropriate direction of the transition,
[animation setType:kCATransitionMoveIn];
[animation setSubtype:kCATransitionFromTop];
// Set the duration and timing function of the transtion -- duration is passed in as a parameter, use ease in/ease out as the timing function
[animation setDuration:0.4];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
[[PickerView layer] addAnimation:animation forKey:@"transitionViewAnimation"];
PickerView.hidden = FALSE;
[[PickerView layer] removeAnimationForKey:@"transitionViewAnimation"];
animation = nil;
}
Upvotes: 4
Reputation: 826
A good idea is to bring it up like any other keyboard. Start it offscreen. Start an animation, set it to a position onscreen, then commit the animation. Otherwise you can do any other crazy view animation you want to do. Fade in, other slide animations, expand into view perhaps?
Upvotes: 0