我想做一个动画效果就是一个imageview逐渐缩小变透明,然后消失,但是我用了如下代码后发现imageview只会从0.01尺寸变大至原始尺寸,不会变小非常奇怪。请各位帮我指出问题所在,小弟感激不尽
[UIView animationWithDuration:2 animations:^{
[imageview setTransform:(CGAffineTransformMakeScale(0.01,0.01))];
[imageview setAlpha:0];
}
completion:^(BOOL finished){
[imageview removeFromSuperview];
}];
------解决方案--------------------
使用CABasicAnimation 来创建动画效果。具体使用你再查一下。
------解决方案--------------------
试了试好像没有问题
------解决方案--------------------
试试代码:
[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{
}
------解决方案--------------------
不过问题也可能你的方法名字不对,不行的话,你再试试把名字改为:animateWithDuration
[UIView animateWithDuration:2 animations:^{