我有一个应用程序我隐藏并在事件上显示tabbar,下面是我正在使用的方法,当我试图隐藏它时,它工作正常。但是,当我试图让它变得可见时,它不起作用。
-(void)setTabBarVisible:(BOOL)visible animated:(BOOL)animated completion:(void (^)(BOOL))completion {
// RootViewController* tabBarController = (RootViewController*)self.navigationController.parentViewController.parentViewController;
UITabBarController *tabBarController = self.tabBarController;
CGFloat duration = (animated)? 0.3 : 0.0;
CGRect frame = tabBarController.tabBar.frame;
CGFloat height = frame.size.height;
CGFloat offsetY = (visible)? -height : height;
CGRect playerFrame = player.view.frame;
CGRect toolBarFrame = self.toolbar.frame;
[UIView animateWithDuration:duration animations:^{
CGRect fr = CGRectOffset(frame, 0, offsetY);
tabBarController.tabBar.frame = fr;
if((!visible && ![self toolBarOnBottom]) || visible) {
self.toolbar.frame = CGRectOffset(toolBarFrame, 0, offsetY);
[self.toolbar layoutIfNeeded];
}
} completion:completion];
}
我第二次调试代码时调用此方法使其可见,tabbar框架为零,我认为这是问题所在。我正在使用iOS 11 SDK在Xcode 9上测试它。我不确定安全区域是否与此有关。
任何帮助都将不胜感激。
答案 0 :(得分:0)
由于我想获得一个有效的解决方案,最终使用了这个,完美的自动布局和安全区域