0

这是我为图像提供交叉溶解效果的代码

- (void)viewDidLoad
{
    [super viewDidLoad];
    typedef enum
    {
        UIViewAnimationOptionTransitionCrossDissolve,
        UIViewAnimationOptionTransitionCurlDown,
        UIViewAnimationOptionTransitionCurlUp,
        UIViewAnimationOptionTransitionFlipFromBottom,
        UIViewAnimationOptionTransitionFlipFromLeft
} UIViewAnimationOptions;


    [UIView animateWithDuration:1.0 animations:^(void){

    [UIView setAnimationTransition: UIViewAnimationOptionTransitionCrossDissolve forView:img cache: YES];

    } completion:^(BOOL finished){
        [UIView animateWithDuration:1.0 animations:^(void){
            [UIView setAnimationTransition: UIViewAnimationOptionTransitionCrossDissolve forView:img cache: YES];
        } completion:^(BOOL finished){

        }];
    }];
}

但是我收到从枚举类型'enum UIViewAnimationOption 到不同枚举类型uiviewanimation 转换的警告隐式转换。

但是,如果我给UIViewAnimationTransitionFlipFromRight,UIViewAnimationTransitionCurlUp .....它正在工作,但 animatewithoptions 正在发出警告。

谁能帮我?

4

2 回答 2

2

您正在使用UIViewAnimationOption.

定义的枚举UIViewAnimationTransition是:

typedef enum {
   UIViewAnimationTransitionNone,
   UIViewAnimationTransitionFlipFromLeft,
   UIViewAnimationTransitionFlipFromRight,
   UIViewAnimationTransitionCurlUp,
   UIViewAnimationTransitionCurlDown,
} UIViewAnimationTransition;

请检查UIView 类以供参考。

同时删除您定义的枚举,不需要它。iOS 已经有了UIView类的枚举。

于 2013-03-19T08:07:56.953 回答
0

您不需要 typedef 动画选项枚举,它已经完成

错误告诉您出了什么问题,UIViewAnimationOption当方法需要一个类型时,您正在传递一个类型UIViewAnimationTransition

动画过渡的有效选项是:

typedef enum {    
    UIViewAnimationTransitionNone,    
    UIViewAnimationTransitionFlipFromLeft,   
    UIViewAnimationTransitionFlipFromRight,    
    UIViewAnimationTransitionCurlUp,    
    UIViewAnimationTransitionCurlDown, 
} UIViewAnimationTransition; 
于 2013-03-19T08:01:53.977 回答