![](/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.