Sanchit Paurush Sanchit Paurush - 1 year ago 87
iOS Question

How to add animation while changing the hidden mode of a uiview?

I want to add animation to a view while changing its hidden mode i.e


I have added a button in navigationbar. When we click on it the new view is set to be unhide. It draws at the upper of the navigation table.

Answer Source

Unfortunately, hidden is not a property that is animatable through UIView animations. I think your best bet may be to use one of the animations @Erik B suggested, or start dabbling with Core Animations which are much more powerful. Take a glance at the documentation for UIView animations and Core Animations.

I achieved something like what your suggesting by using UIView animations to slide the new view from below another view. This made it appear like a drawer sliding out. If you want to do something like that, you need to intercept the touch up inside event and place the animation code there.

- (IBAction)buttonClicked:(id)sender {
    [UIView animateWithDuration:0.5
                     animations:^(void) {
                        self.myView.frame = /* set the frame here */
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download