2012-12-21 40 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