iOS 技巧

iOS开发遇到的问题汇总(持续更新~)

2020-09-18  本文已影响0人  LazyLoad

设置TabBar文字的选中颜色和未选中颜色

// 设置未选中文字颜色
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor colorWithHexString:@"#535353"]];
// 设置选中文字颜色
[[UITabBar appearance] setTintColor:[UIColor colorWithHexString:@"#DF0615"]];

push页面的时候,会闪一下黑色

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    // 解决Push页面时候,导航栏会闪一下黑色
    self.view.backgroundColor = [UIColor whiteColor];

    [super pushViewController:viewController animated:animated];
}

iOS 14 push多个控制器,返回到根控制器,发现tabbar消失的问题

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    
    if (self.childViewControllers.count > 0) {

        viewController.hidesBottomBarWhenPushed = YES;
        
        // 解决push多个控制器后,popToRootViewController TabBar消失
        if (self.childViewControllers.count > 1) {
            viewController.hidesBottomBarWhenPushed = NO;
        }
    }
   
 
    [super pushViewController:viewController animated:animated];
}
上一篇下一篇

猜你喜欢

热点阅读