UIView animation does not animate at first try?
- by Bacalso Vincent
Considering that my _palette's frame is like this:
_palette.frame = CGRectMake(0,480,320,200);
I have this code here to slide up/down a UIView:
if(![_pallete superview]) {
[self.view addSubview:_pallete];
[self.view insertSubview:_tempViewPaletteListener belowSubview:_pallete];
[UIView animateWithDuration:0.3
animations:^{
_pallete.top -= kPaletteHeight;
}
completion:^(BOOL isFinished) {
}];
} else {
[UIView animateWithDuration:0.3
animations:^{
_pallete.top += kPaletteHeight;
}
completion:^(BOOL isFinished) {
[_tempViewPaletteListener removeFromSuperview];
[_pallete removeFromSuperview];
}];
}
*the _tempViewPaletteListener is just a view with a tap gesture use to dismiss the palette*
The problem is when I first try to run code here, the _palette view will just stiffly display right away.
What I expected is, it should slide up the _palette view.
Though it works fine after the first try