开发者

Animation while adding subview by modifying bounds "shoots over"

开发者 https://www.devze.com 2023-01-12 11:50 出处:网络
Goal is to animate a subview while adding it. [[videoDetailsViewController view] setBounds:CGRectMake(0, -480, 320, 480)];

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消