UIView 动画后顶部有间隙
我有一个 tabbarview 应用程序,其中一个选项卡中有一个按钮。当按下该按钮时,会发生一些事情,用户将切换到另一个选项卡。
我在该按钮中制作了一个动画:
UIView * fromView = self.tabBarController.selectedViewController.view;
UIView * toView = [[self.tabBarController.viewControllers objectAtIndex:0] view];
[UIView transitionFromView:fromView
toView:toView
duration:0.6
options:(UIViewAnimationOptionTransitionCurlDown)
completion:^(BOOL finished) {
if (finished) {
self.tabBarController.selectedIndex = 0;
}
}];
这是我从 获得的在这里。然而问题是,动画之后,屏幕顶部似乎有一个与状态栏一样高的间隙。有谁知道这是什么原因造成的?当动画完成时(当我们执行 self.tabBarController.selectedIndex = 0
顺便说一句,如果我将动画交换为其他内容甚至没有动画,问题仍然存在。
附加信息,这是帧详细信息:
from frame: x:0.000000, y:0.000000, w:320.000000, h:411.000000
to frame: x:0.000000, y:0.000000, w:320.000000, h:431.000000
I have a tabbarview application that has a button in one of the tabs. When Pressing that button, something will happen, and the user will be switched to another tab.
I made an animation in that button:
UIView * fromView = self.tabBarController.selectedViewController.view;
UIView * toView = [[self.tabBarController.viewControllers objectAtIndex:0] view];
[UIView transitionFromView:fromView
toView:toView
duration:0.6
options:(UIViewAnimationOptionTransitionCurlDown)
completion:^(BOOL finished) {
if (finished) {
self.tabBarController.selectedIndex = 0;
}
}];
Which I got from here. However the problem is that after animating, I seem to have a gap on the top of the screen that is about as high as the status bar. Does anyone know what's causing this? This gap quickly closes when the animation finishes (which is when we do self.tabBarController.selectedIndex = 0
By the way, the problem still persist if I swap the animation to something else or even without animation.
Additional info, here's the frame details:
from frame: x:0.000000, y:0.000000, w:320.000000, h:411.000000
to frame: x:0.000000, y:0.000000, w:320.000000, h:431.000000
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标签栏控制器的区域还覆盖状态栏下方的区域。因此它自己的客户端视图的 origin.y 为 20。
因此,您需要在调用转换之前正确设置传入视图框架。
The tab bar controller's area also covers the area underneath the status bar. So it's own client view has origin.y of 20.
Thus you need to set the incoming view frame correctly before invoking the transition.
我找到了一种非常老套的方法:
任何可以向我解释为什么我必须这样做以及更优雅的方法的人都会得到答案。
I've found a very hacky way to do it:
Anyone that can explain to me why I had to do this and a more elegant way to do this will get the answer accepted.