Animation while adding subview by modifying bounds "shoots over"
Goal is to animate a subview while adding it.
[[videoDetailsViewController view] setBounds:CGRectMake(0, -480, 320, 480)];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3f];
[self.view addSubview:[videoDetailsViewController view]];
[[videoDetailsViewController view] setBounds:CGRectMake(0, 0, 320, 480)];
[UIView commitAnimations];
I was expecting the subview to come up from the bottom and end up aligned to the top left corner. But the animation "shoots over", i.e. some of the top part of the subview is not visible anymore.开发者_如何学Go
The strange thing is: When I switch to another tab and switch back, the added view is displayed correctly, so it seems like some animation refresh problem? (the view is embedded in a UITabbar)
Try adding the subview outside of the animation block.
精彩评论