当我在willRotateToInterfaceOrientation
和animates
之间切换时,我已经实施了方法orientation
和我的iPhone应用landscape
移动portrait
。
我的问题是:是否可以使用不同类型的animation
?是否有其他内置的animations
我可以用于transition
?或者我可以自己篡改它吗?任何人都可以向我展示更改animation
的代码示例吗?
答案 0 :(得分:2)
绝对有可能。这是一个自定义动画,我将几个视图移动到不同的地方:
- (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];
}
这很好用,因为每张图像都飞过屏幕,然后降落在一个新的位置。你可以使用这样的东西来创造各种效果。