我想做一个动画效果就是一个imageview逐渐缩小变透明,然后消失,但是我用了如下代码后发现imageview只会从0.01尺寸变大至原始尺寸,不会变小非常奇怪。请各位帮我指出问题所在,小弟感激不尽[UIView animationWithDuration:2 animations:^{
[imageview setTransform:(CGAffineTransformMakeScale(0.01,0.01))];
[imageview setAlpha:0];
}
completion:^(BOOL finished){
[imageview removeFromSuperview];
}];

解决方案 »

  1.   

    使用CABasicAnimation 来创建动画效果。具体使用你再查一下。
      

  2.   

    试试代码:[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{}
      

  3.   

    不过问题也可能你的方法名字不对,不行的话,你再试试把名字改为:animateWithDuration    [UIView animateWithDuration:2 animations:^{
      

  4.   

    问题已解决,发现一个IOS的问题。
    其实这个动画中我还加入了旋转效果,但是发现必须先给imageview添加旋转效果再添加缩放效果才能正常运行,如果两个循序颠倒就会出现我上面所提到的问题,非常奇怪。
    我本人同时也做android开发,android这方面做的比较好,不会出现这样的怪现象!