views:

223

answers:

2

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

A: 

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?

kidnamedlox
+2  A: 

Yes , you can animate 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;

}

Note: Please include Quartz framework(QuartzCore.framework) and import its header file( QuartzCore/QuartzCore.h) to your controller.

Jay Vachhani
Thanks my dear frnd
shinto Joseph