2013-05-07 75 views
0

我不得不用幾個按鈕來製作動畫,看起來像是從下面旋轉到屏幕上並設法做到這一點。爲了解決工作,我需要改變按鈕的方向上viewDidLoad中是這樣的:按鈕更改捕捉的觸摸方向。 IOS

for (UIButton* button in self.shareButtons) { 
    button.imageView.image = [UIImage imageWithCGImage:button.imageView.image.CGImage 
               scale:1.0 orientation: UIImageOrientationDownMirrored]; 
} 

這一切工作正常,但是當觸摸一個按鈕,內抓它,然後取消該方向的變化和按鈕「downmirrored 「由動畫引起的。

如何防止/避免它?

在此先感謝。

+0

爲什麼你認爲你需要改變圖像的方向?你爲什麼不用(仿射)變換來做這件事? – Wain 2013-05-07 15:18:48

回答

0

嘗試設置圖像這樣

[button setImage:[UIImage imageWithCGImage:button.imageView.image.CGImage 
       scale:1.0 orientation: UIImageOrientationDownMirrored] 
       forState:UIControlStateNormal]; 

也看看我的其他answer用於旋轉圖像

在評論應用變換提到的也是一個不錯的選擇

button.transform = CGAffineTransformMakeRotation((180 * M_PI)/180); 

將旋轉180度的UIButton。

+0

它工作正常。謝謝! – anks 2013-05-08 09:02:06