![](/img/trans.png)
[英]Calling layoutIfNeeded inside UIView animation block cause subviews to move earlier
[英]UIView animation block not animation view's subviews
我无法使用以下代码实现任何动画:
if (self.segmentControl.selectedSegmentIndex == 0) {
[UIView transitionFromView:tableView
toView:mapView
duration:1.0
options:UIViewAnimationTransitionFlipFromLeft
completion:nil
];
}
if (self.segmentControl.selectedSegmentIndex == 1) {
[UIView transitionFromView:mapView
toView:tableView
duration:1.0
options:UIViewAnimationTransitionFlipFromRight
completion:nil
];
}
视图实际上是交换,但没有任何动画。 这很奇怪。 我也曾尝试交换mapView
和tableView
与self.view.subviews
像这样( objectAtIndex:0
是一个toolBar
):
if (self.segmentControl.selectedSegmentIndex == 0) {
[UIView transitionFromView:[self.view.subviews objectAtIndex:1]
toView:[self.view.subviews objectAtIndex:2]
duration:1.0
options:UIViewAnimationTransitionFlipFromLeft
completion:nil
];
}
if (self.segmentControl.selectedSegmentIndex == 1) {
[UIView transitionFromView:[self.view.subviews objectAtIndex:2]
toView:[self.view.subviews objectAtIndex:1]
duration:1.0
options:UIViewAnimationTransitionFlipFromRight
completion:nil
];
}
您使用的是错误的选项。 使用此方法,您应该使用常量UIViewAnimation Option TransitionFlipFromLeft
和…Right
而不是。
旧常量UIViewAnimationTransitionFlipFromLeft
和…Right
应仅用于非基于块的方法+setAnimationTransition:…
这些常数分别具有值1和2,而我上面提到的值具有值1 << 20和2 << 20,它们完全不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.