我想围绕一个 anchor 将 ImageView 旋转 90 度。你可以在这里看到我想要实现的目标。
我有这段代码。
CGFloat DegreesToRadians(CGFloat degrees)
{
return degrees * M_PI / 180;
}
NSNumber* DegreesToNumber(CGFloat degrees)
{
return [NSNumber numberWithFloat:
DegreesToRadians(degrees)];
}
-(IBAction)rotate:(id)sender{
CABasicAnimation *rotationAnimation = [CABasicAnimation
animationWithKeyPath:@"transform.rotation.y"];
[rotationAnimation setFromValue:DegreesToNumber(0)];
[rotationAnimation setToValue:DegreesToNumber(90)];
[rotationAnimation setDuration:3.0f];
[rotationAnimation setRepeatCount:1];
[[[self imgShare] layer] addAnimation:rotationAnimation forKey:@"rotate"];
}
有一个 View 问题。首先,当它旋转 90 度时,它会立即翻转回原来的状态。我也不知道如何围绕 anchor 转动它。
有什么帮助吗?
最佳答案
试试这个:
self.imgShare.transform = CGAffineTransformMakeRotation(M_PI/2);
关于ios - 围绕 anchor 将图像旋转 90 度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17444391/