首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CATransform3DRotate和UIImageView

CATransform3DRotate和UIImageView
EN

Stack Overflow用户
提问于 2010-07-21 07:10:36
回答 1查看 6.2K关注 0票数 8

我正在用下面的代码为一个UIImage视图添加动画

代码语言:javascript
复制
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
animation.duration = 1;
animation.toValue = [NSNumber numberWithFloat:M_PI];
animation.fromValue = [NSNumber numberWithInt:0];
[square.layer addAnimation:animation forKey:@"rotation"];

一切正常,但我的数组在动画结束时采用了它原来的位置。我查看了layer属性,发现:

代码语言:javascript
复制
[square.layer setTransform:CATransform3DRotate(HERE, -M_PI, 0, 0, 0)];

我不知道写什么来代替“这里”。你能帮我个忙吗?非常感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-07-21 08:44:28

CATransform3DRotate()将要应用旋转的变换作为其第一个参数。如果你想旋转图层的变换,你可以使用

代码语言:javascript
复制
[square.layer setTransform:CATransform3DRotate(square.layer.transform, -M_PI, 0, 0, 0)];

也就是说,如果您遇到的问题是层在动画结束时突然返回到开始位置,则只需将动画的removedOnCompletion属性设置为NO,并将其fillMode属性设置为kCAFillModeForwards

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

https://stackoverflow.com/questions/3295114

复制
相关文章

相似问题

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