我正在尝试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"];