我知道它很疯狂,但在这里:
我将splashView加载到我的应用:viewDidLoad:
[self.view addSubview:splashView];
UIViewAnimationOptions options = UIViewAnimationOptionCurveLinear;
[UIView animateWithDuration:0.5 delay:3.0 options:options animations:^{
splashView.alpha = 0.0f;
splashView.frame = CGRectMake(512,384,-10,-10);
}
completion:^(BOOL finished){
[splashView removeFromSuperview];
}];
这里的代码没什么特别的。
然而,当我尝试通过按钮加载与动作相同的视图时 没有发生:
-(IBAction)showSplash:(id)sender {
[self.view addSubview:splashView];
UIViewAnimationOptions options = UIViewAnimationOptionCurveLinear;
[UIView animateWithDuration:0.5 delay:3.0 options:options animations:^{
splashView.alpha = 0.0f;
splashView.frame = CGRectMake(512,384,-10,-10);
}
completion:^(BOOL finished){
[splashView removeFromSuperview];
}];
}
为什么会这样?
顺便说一句,如果我不在viewDidLoad上加载splashView然后使用按钮(动作)它可以正常工作!
这是正常行为吗?
答案 0 :(得分:2)
在淡出飞溅视图之前重置alpha值。
splashView.alpha = 1.0f;