我已经实现了方法willRotateToInterfaceOrientation
,当我在landscape
和portrait
之间切换时,我的iPhone应用程序很好地实现了animates
和orientation
的移动。
我的问题是:有可能拥有不同类型的animation
吗?是否有其他内置的animations
可以用于该transition
?或者我可以自己篡改它吗?有人能给我看一下更改animation
的代码示例吗?
这绝对是可能的。这是一个自定义动画,我做了几个视图移动到不同的地方:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
[UIView beginAnimations:nil context:NULL]; {
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
if (toInterfaceOrientation == UIInterfaceOrientationPortrait ||
toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
[myImage setCenter:CGPointMake(384.0,170.0)];
[firstLabel setCenter:CGPointMake(235.0,358.0)];
[secondLabel setCenter:CGPointMake(519.0,358.0)];
[button0 setCenter:CGPointMake(164.0,508.0)];
[button1 setCenter:CGPointMake(384.0,508.0)];
[button2 setCenter:CGPointMake(604.0,508.0)];
[button3 setCenter:CGPointMake(274.0,666.0)];
[button4 setCenter:CGPointMake(494.0,666.0)];
[button5 setCenter:CGPointMake(164.0,824.0)];
[button6 setCenter:CGPointMake(384.0,824.0)];
[button7 setCenter:CGPointMake(604.0,824.0)];
[button8 setCenter:CGPointMake(164.0,954.0)];
[button9 setCenter:CGPointMake(604.0,954.0)];
} else {
[myImage setCenter:CGPointMake(350.0,173.0)];
[firstLabel setCenter:CGPointMake(844.0,66.0)];
[secondLabel setCenter:CGPointMake(844.0,114.0)];
[button0 setCenter:CGPointMake(140.0,450.0)];
[button1 setCenter:CGPointMake(388.0,450.0)];
[button2 setCenter:CGPointMake(636.0,450.0)];
[button3 setCenter:CGPointMake(884.0,450.0)];
[button4 setCenter:CGPointMake(140.0,638.0)];
[button5 setCenter:CGPointMake(388.0,638.0)];
[button6 setCenter:CGPointMake(636.0,638.0)];
[button7 setCenter:CGPointMake(884.0,638.0)];
[button8 setCenter:CGPointMake(844.0,190.0)];
[button9 setCenter:CGPointMake(844.0,280.0)];
}
} [UIView commitAnimations];
}
当每个图像都在屏幕上飞到一个新的位置时,效果非常好。你可以用这样的东西来创造各种各样的效果。