我有一个UIView对象。当我改变全局变量角度时,它会旋转。我有一个函数可以从它的superview中删除这个UIView并重绘它。我添加了一个按钮。当用户按下这个按钮时,我需要启动一个动画。在每一步中,我都需要改变角度并调用我的重绘函数。所以我期望看到的效果是,我的视图在旋转。代码如下:
-(IBAction)animate:(id)sender
{
NSLog(@"animate: called");
[UIView animateWithDuration:0.7
delay:0.0
options: UIViewAnimationCurveEaseOut
animations:^{
angle=angle+5.0;
if (angle>360)
{
angle=angle-360;
}
else if(angle<0)
{
angle=angle+360;
};
NSLog(@"inner angle: %g", angle);
[self transform]; //this is my redraw function. it redraws my view depending on global variable value angle.
}
completion:NULL];
NSLog(@"finalAngle: %g", angle);
}为什么这个动画不能正常工作?
发布于 2011-12-05 21:56:58
UIView动画仅支持以下属性
@property frame
@property bounds
@property center
@property transform
@property alpha
@property backgroundColor
@property contentStretch您必须使用核心动画框架来执行动画
发布于 2012-08-20 23:59:11
您可以为transform属性设置动画。但是,使用transform属性执行旋转要比使用CA Framework复杂。我发现这篇文章很有帮助:UIView Infinite 360 degree rotation animation?
https://stackoverflow.com/questions/8386028
复制相似问题