7
我已經在頂部創建了一個分段控件的簡單應用程序。當我點擊控件的兩個片段之一時,UIImageView開始旋轉。我有一個重置按鈕掛鉤設置其轉換爲CGAffineTransformIdentity。CGAffineTransformIdentity在多次轉換後不重置UIImageView?
當執行視圖旋轉動畫的方法通過來回切換片段而被第二次調用時,會發生該問題。點擊重置只會刪除最近的動畫。我必須再次切換片段才能讓動畫完全停止並重置。
當我選擇旋轉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;
威爾動畫持續時間(0.2秒),將增加的預期效果?請多說明一下.. – HDdeveloper
您可以設置您的期望值,我只是表明它有持續時間選項。乾杯:) –
問題說他已經設置了CGAffineTransformIdentity並且它不起作用 – trapper