I have a UITextField
searchbox, at first it's hidden, i want to show it with animation and it works. But when i hide it again, the animation happens suddenly, not with defined time in animation.
Here is my code :
[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];
Must use .alpha
to hide or show UIView
.
Correct code is :
[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];