这是我的代码,用于给图像添加交叉溶解效果
- (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到不同的枚举类型uiviewanimationtransition。
但是如果我给UIViewAnimationTransitionFlipFromRight,UIViewAnimationTransitionCurlUp .....它正在工作,但是animatewithoptions给出警告。
有人能帮我吗?您正在使用UIViewAnimationOption
的enum。
为UIViewAnimationTransition
定义的enum为:
typedef enum {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
} UIViewAnimationTransition;
请参考UIView类。
也删除你定义的enum,没有必要。iOS已经有UIView
类的enum
你不需要定义动画选项enum的类型,它已经完成了
错误告诉你什么是错的,当方法期望UIViewAnimationTransition
时,你正在传递UIViewAnimationOption
类型
动画转换的有效选项是:
typedef enum {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
} UIViewAnimationTransition;