我无法使用以下代码实现任何动画:
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
];
}
View 实际上是在交换,只是没有任何动画。这很奇怪。我也试过像这样用 self.view.subviews
交换 mapView
和 tableView
(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
];
}
最佳答案
您使用了错误的选项。使用此方法,您应该使用 the constants UIViewAnimation<b>Option</b>TransitionFlipFromLeft
and …Right
相反。
旧常量 UIViewAnimationTransitionFlipFromLeft
和 …Right
应该只用于非基于 block 的方法 +setAnimationTransition:…
.这些常量的值分别是 1 和 2,而我上面提到的那些值是 1 << 20 和 2 << 20,这是完全不同的。
关于ios - UIView 动画 block 不是动画 View 的 subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4055113/