首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIView animateWithDuration不工作

UIView animateWithDuration不工作
EN

Stack Overflow用户
提问于 2011-12-05 21:26:57
回答 2查看 2.1K关注 0票数 1

我有一个UIView对象。当我改变全局变量角度时,它会旋转。我有一个函数可以从它的superview中删除这个UIView并重绘它。我添加了一个按钮。当用户按下这个按钮时,我需要启动一个动画。在每一步中,我都需要改变角度并调用我的重绘函数。所以我期望看到的效果是,我的视图在旋转。代码如下:

代码语言:javascript
复制
-(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);
}

为什么这个动画不能正常工作?

EN

回答 2

Stack Overflow用户

发布于 2011-12-05 21:56:58

UIView动画仅支持以下属性

代码语言:javascript
复制
@property frame
@property bounds
@property center
@property transform
@property alpha
@property backgroundColor
@property contentStretch

您必须使用核心动画框架来执行动画

票数 1
EN

Stack Overflow用户

发布于 2012-08-20 23:59:11

您可以为transform属性设置动画。但是,使用transform属性执行旋转要比使用CA Framework复杂。我发现这篇文章很有帮助:UIView Infinite 360 degree rotation animation?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8386028

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档