我有一個向右移動圖像的動畫,然後當我放開按鈕時停止。我需要圖像的幀在不同的時間是不同的,所以我用CGRect變量代替myImageView.frame = CGRectMake。但是當我使用可變圖像跳躍回到原來的位置時,每次我放開,而不是像往常一樣停下來。如果使用CGRect變量代替CGRectMake,動畫不起作用
if (myInt == 2) {
MyCGRect = CGRectMake(myImageView.frame.origin.x,myImageView.frame.origin.y,18,42);
} else {
MyCGRect = CGRectMake(myImageView.frame.origin.x,myImageView.frame.origin.y,35,28);
}
-(IBAction)holdToMakeImageMove:(id)sender
{
//!!!!!This Works!!!!!!
myImageView.frame = CGRectMake(myImageView.frame.origin.x,myImageView.frame.origin.y,18,42);
//!!!!!!THIS doesnt work
myImageView.frame = MyCGRect;
//...animation
}
您是否在調試器中檢查了「MyCGRect」的值?也許它與'frame'值相同? – Stream 2012-08-14 21:20:27
@Stream我做了,事實證明myCGRect總是停留在同一個地方。它不應該改變,如果它有myImageView.frame.origin.x? – 2012-08-14 22:58:06