イメージビューをアンカー ポイントを中心に 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"];
}
ビューの問題があります。最初に 90 度回転すると、すぐに元の状態に戻ります。また、アンカーポイントを中心に回転させる方法もわかりません。
助けはありますか?