我有一个UITextField
搜索框,起初它是隐藏的,我想用动画显示它并且它可以工作。但是当我再次隐藏它时,动画突然发生,而不是动画中定义的时间。
这是我的代码:
[UIView transitionWithView:searchbox duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{searchbox.hidden = NO;}completion:NULL];
[UIView transitionWithView:searchbox duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{searchbox.hidden = YES;}completion:NULL];
必须用于.alpha
隐藏或显示UIView
。
正确的代码是:
[UIView transitionWithView:searchbox duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{searchbox.alpha=1;}completion:NULL];
[UIView transitionWithView:searchbox duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{searchbox.alpha=0;}completion:NULL];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句