An example of how UIViewAnimationOptionLayoutSubviews works?

Apple's documentation describes UIViewAnimationOptionLayoutSubviews as:

Lay out the subitems during the commit so that they are animated along with their parent.

Here is an example of the code that interests me. I want to animate -layoutSubviews of detailView ; however, they don't seem to match the detailView , so I'm not sure what effect it really has.

  void (^animation) () = ^ { [self.detailView setNeedsLayout]; [self.detailView layoutIfNeeded]; }; [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionLayoutSubviews animations:^{ animation(); } completion:nil]; 
+8
ios core-animation
source share
1 answer

Since you want your second animation to come from the current state of your first animation (whether it is finished or not), I recommend using the UIViewAnimationOptionLayoutSubviews parameter when setting up the second animation.

 [UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionLayoutSubviews animations:^{ CGAffineTransform settingsTransform = CGAffineTransformMakeTranslation(self.animatedView.frame.size.width, 0); self.animatedView.transform = settingsTransform; } completion:nil]; 
0
source share

All Articles