CGAffineTransformIdentity是否在多次转换后未重置UIImageView?

问题描述 投票:8回答:1

我创建了一个简单的应用,其顶部具有分段控件。当我单击控件的两个部分之一时,UIImageView开始旋转。我有一个重置按钮,可以将其转换设置为CGAffineTransformIdentity。

当通过反复来回切换段再次​​调用执行视图旋转动画的方法时,会发生此问题。击中重置只会删除最新的动画。我必须第二次切换片段才能使动画完全重置而停止。

当我选择要旋转UIImageView的段时,将调用以下代码;当我在段之间单击时,显然将第二次调用。

// Begin the animation block and set its name
[UIView beginAnimations:@"Rotate Animation" context:nil];

// Set the duration of the animation in seconds (floating point value)
[UIView setAnimationDuration:0.5];

// Set the number of times the animation will repeat (NSIntegerMax setting would repeat indefinately) (floating point value)
[UIView setAnimationRepeatCount:NSIntegerMax];

// Set the animation to auto-reverse (complete the animation in one direction and then do it backwards)
[UIView setAnimationRepeatAutoreverses:YES];

// Animation curve dictates the speed over time of an animation (UIViewAnimationCurveEaseIn, UIViewAnimationCurveEaseOut, UIViewAnimationCurveEaseInOut, UIViewAnimationCurveLinear)
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

// Changes the imageViews transform property to rotate the view using CGAffineTransformRotate
// CGAffineTransformRotate(transformToStartFrom, angleToRotateInRadians)
// Starting transform property can be set to CGAffineTransformIdentity to start from views original transform state
// This can also be done using CGAffineTransformMakeRotation(angleInRadians) to start from the IdentityTransform without implicitly stating so
self.imageView.transform = CGAffineTransformRotate(self.imageView.transform, degreesToRadians(90));

[UIView commitAnimations];

重置按钮调用此代码-

self.imageView.transform = CGAffineTransformIdentity;

我创建了一个简单的应用,其顶部具有分段控件。当我单击控件的两个部分之一时,UIImageView开始旋转。我挂了一个重置​​按钮来设置其变换...

ios objective-c core-graphics cgaffinetransform
1个回答
7
投票

尝试一下

© www.soinside.com 2019 - 2024. All rights reserved.