Apple的文档将UIViewAnimationOptionLayoutSubviews描述为:
Lay out subviews at commit time so that they are animated along with
their parent.
这是我感兴趣的代码示例.我希望为detailView的-layoutSubviews设置动画;但是,它似乎没有布局detailView的子视图,所以我不确定它实际上有什么影响.
void (^animation) () = ^ { [self.detailView setNeedsLayout]; [self.detailView layoutIfNeeded]; }; [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionLayoutSubviews animations:^{ animation(); } completion:nil];
解决方法
由于您希望第二个动画从第一个动画的当前状态(无论是否完成)发生,我建议在设置第二个动画时使用UIViewAnimationOptionLayoutSubviews选项.
[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];