0

I'm trying to rearrange the content of my UIView based on a user event (rotation), and I've found that I would like to combine a translation animation, and the fading out and fading in of various controls.

Since this seems to depend on the "options" of the animate functions, I assumed that I need to launch two animations concurrently with different options, as follows. The "Layout_Set" function assigns new "frames" to all of my controls, which works fine. The "setHidden" in the block of the other animation is intended to fade out a single control on rotation.

However... doesn't work. Is this the right way to (a) launch concurrent animations and (b) to fade out a control?

Thanks very much for any help.

 [UIView animateWithDuration:duration
                          delay: 0.0
                        options: UIViewAnimationOptionCurveEaseIn +  
 UIViewAnimationOptionCurveEaseOut + UIViewAnimationOptionBeginFromCurrentState
                     animations:^{

                         [self Layout_Set];
                     }
                     completion:^(BOOL finished){}];

    [UIView animateWithDuration:duration
                          delay: 0.0
                        options: UIViewAnimationOptionCurveEaseIn +   
 UIViewAnimationOptionCurveEaseOut + UIViewAnimationOptionBeginFromCurrentState
                     animations:^{

                         [self.UIImageQRCameraLogo setHidden:true];

                     }
                     completion:^(BOOL finished){}];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Chris
  • 629
  • 1
  • 10
  • 28
  • Does it not do what you want if you move the setHidden: statement into the first animations block, and eliminate the second animateWithDuration? – rdelmar Sep 11 '14 at 19:59
  • Also, options are combined using bitwise or (`|`) – David Rönnqvist Sep 11 '14 at 20:34
  • @rdelMar If I put the setHidden in the first animation, then it just immediately vanishes. I want it to fade out. – Chris Sep 11 '14 at 20:45
  • @Davie I think I do that if I want multiple options to apply to one animation, correct? In my case I want one (set of) option(s) to apply to one animation, and a different (set of) options to apply to another. Same thing, for example, if I wanted two different "delays." Is two separate animation calls like above the way to do that? Thanks. – Chris Sep 11 '14 at 20:47
  • Sorry, you should put self.UIImageQRCameraLogo.alpha = 0 (rather than setHidden), and that should fade out over the duration time. – rdelmar Sep 11 '14 at 21:07
  • @rdelmar thanks! If I wanted the fade to happen quicker than the translation, should I package it in a separate animation command with a shorter duration, similar to above? Is that the "right" way? – Chris Sep 11 '14 at 21:44
  • Use animateKeyframesWithDuration:delay:options:animations:completion:. You can add as many keyframes (addKeyframeWithRelativeStartTime:relativeDuration:animations:) as you want to that and give each a delay and duration with respect to the start of the overall animation. – rdelmar Sep 11 '14 at 21:48

0 Answers0