I am begining to use UIView animation. And can't get such code working properly. Here is what i have
if(_Language.hidden == true)
{
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^ {
_Language.alpha = 1.0;
}
completion:^(BOOL finished) {
_Language.hidden = false;
}];
}
else
{
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^ {
_Language.alpha = 0.0;
}
completion:^(BOOL finished) {
_Language.hidden = true;
}];
}
This code works in such way. Hide animation works as expected. But show animation just waits 1 sec, and pops the object without any transition. Can anyone tell me what I am missing here?
You are changing the hidden
attribute to true only after the animation is over, so it doesn't appear until the animation is completed. you should do it before the animation begins :
if(_Language.hidden == true)
{
_Language.hidden = false;
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^ {
_Language.alpha = 1.0;
}];
}
Your _Language.hidden
is set as true
and hence when it is animating, nothing will appear on the screen. You need to make it visible before animating. Set the hidden property to false and then show the animation. The reverse will work only for hiding when you add it in completion block.
_Language.hidden = false;
[UIView animateWithDuration:1.0 ...
and remove it from completion block,
completion:^(BOOL finished) {
}];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.