views:

54

answers:

1

I'd like to build a preferences screen in my iOS app that has a segmented control at the top and, depending on its state, it will determine which sliders and switches are visible, as well as where they're positioned. When you change the state of the segmented control and the layout of the screen changes, I'd like it to animate smoothly into the new layout. An example of this kind of behavior can be seen in the wireless settings of your iOS device, as you click around on the various segmented controls, you can see the layout animating.

  1. I understand how to hide and reposition the controls, but how do I animate it? I'm used to specifying "YES" for a "willAnimate" parameter, but these hide and reposition functions don't include it.
  2. In interface builder, how should I create multiple layouts of controls in a single view? Do I just position controls on top of each other?

Thanks so much in advance for all your help!

+1  A: 

1) Something like this:

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1]; //1 sec duration
    [UIView setAnimationDelegate:self];
    [UIView  setAnimationDidStopSelector:@selector(myTransitionDidStop:finished:context:)];
            //what you want to animate goes here.....

    [UIView commitAnimations];

Also, myTransitionDidStop:finished:context: is a callback method that is executed after the animation is completed. It should be optional.

2) Yes, just hide all elements. Determine at runtime which ones to display.

christo16
Thanks, christo16, I'll try it out!
BeachRunnerJoe