2012-12-21 37 views
0

我想創建一個動畫,使得imageView變得越來越小,透明,然後消失。我試過下面的代碼,它不起作用,運行時它會從0.01尺寸增加到原始尺寸。我無法弄清楚問題出在哪裏。iOS-UImageView縮放動畫不起作用

非常感謝!

[UIView animationWithDuration:2 animations:^{ 
[imageview setTransform:(CGAffineTransformMakeScale(0.01,0.01))]; 
[imageview setAlpha:0]; 
} 
completion:^(BOOL finished){ 
[imageview removeFromSuperview]; 
}]; 
+0

以U R電話驗證碼哪種方法? – samfisher

回答

0

試試這個代碼:

[UIView animationWithDuration:2 animations:^{ 
CGAffineTransform *transform = CGAffineTransformScale(imageView.transform, 0.01, 0.01); 
[imageview setTransform:transform]; 
[imageview setAlpha:0]; 
} 
completion:^(BOOL finished){ 
[imageview removeFromSuperview]; 
}]; 

這將需要在考慮現有的ImageView的變換。 (是否有機會將變換應用於此圖像視圖?)

另一個可以嘗試的方法是將UIViewAnimationOptionBeginFromCurrentState 作爲動畫方法的選項。您將不得不使用:

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion{ 

} 
0

實際上,您的方法名稱似乎不正確。正確的方法是animateWithDuration

[UIView animateWithDuration:2 animations:^{ 
+0

我檢查了它,它像夢一樣工作.. – samfisher