iOS动画角度旋转
2019年06月30日
作者:佚名
我正在尝试360度旋转视角,但倾斜度为45度.
像这样
我无法想办法做到这一点.
到目前为止,我已经成功了
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"]; animation.fromValue = @(0); animation.toValue = @(2 * M_PI); animation.duration = 1; [self.layer addAnimation:animation forKey:@"rotation"];
它在y轴上旋转,但我想要的是这个Y轴在旋转之前倾斜45度.
解决方法
首先,您应该看到下面的链接,它解释了“框架”和“边界”之间的差异.
UIView frame,bounds and center
UIView frame,bounds and center
现在,这是我的答案.
/* add the 4 lines below */ self.transform = CGAffineTransformMakeRotation(M_PI_4); self.layer.bounds = CGRectMake(0.0f,0.0f,60.0f,200.0f); self.layer.position = CGPointMake(150.0f,300.0f); CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"]; animation.fromValue = @(0); animation.toValue = @(2 * M_PI); animation.duration = 1; [self.layer addAnimation:animation forKey:@"rotation"];
以上是来客网为你收集整理的iOS动画角度旋转全部内容,希望文章能够帮你解决iOS动画角度旋转所遇到的程序开发问题。
如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。