gpt4 book ai didi

iphone - 如何旋转 UIView、UIImageView 或 CALayer 动画 360˚?

转载 作者:可可西里 更新时间:2023-11-01 04:04:45 24 4
gpt4 key购买 nike

如何在不使用 OpenGL ES 的情况下旋转 UIViewUIImageViewCALayer 动画 360 度?

最佳答案

#import <QuartzCore/QuartzCore.h>

CABasicAnimation *fullRotation;
fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = @(0.0);
fullRotation.toValue = @((360.0 * M_PI)/180.0);
fullRotation.duration = 3.5f;
fullRotation.repeatCount = MAXFLOAT;

[view.layer addAnimation:fullRotation forKey:@"rotation-animation"];

如果你想改变它旋转的 anchor ,那么你可以这样做

CGRect frame = view.layer.frame;
self.anchorPoint = CGPointMake(0.5, 0.5); // rotates around center
self.frame = frame;

关于iphone - 如何旋转 UIView、UIImageView 或 CALayer 动画 360˚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3431776/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com