美文网首页
iOS - 界面偏移、状态栏导航栏显示隐藏

iOS - 界面偏移、状态栏导航栏显示隐藏

作者: HanZhiZzzzz | 来源:发表于2020-06-11 16:29 被阅读0次
       self.automaticallyAdjustsScrollViewInsets = NO;
    
        [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
        [IQKeyboardManager sharedManager].enable = NO;
    

    状态栏颜色设置

        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    
    
        if (@available(iOS 13.0, *)) {
           [UIApplication sharedApplication].statusBarStyle =  UIStatusBarStyleDarkContent;
        } else {
            [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;;
        }
    

    偏移问题

        if (@available(iOS 11.0, *)) {
            self.tableV.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        } else {
            self.automaticallyAdjustsScrollViewInsets = NO;
        }
    
       self.tableV.estimatedRowHeight = 0;
       self.tableV.estimatedSectionHeaderHeight = 0;
       //适配ios11自适应上导航 安全区域
       self.tableV.separatorStyle = UITableViewCellSeparatorStyleNone;
       SEL selector = NSSelectorFromString(@"setContentInsetAdjustmentBehavior:");
       if ([self respondsToSelector:selector]) {
           IMP imp = [self methodForSelector:selector];
           void (*func)(id, SEL, NSInteger) = (void *)imp;
           func(self, selector, 2);
    
       }
    

    隐藏状态栏

    [UIApplication sharedApplication].statusBarHidden = YES;
    

    隐藏导航栏

        [self.navigationController setNavigationBarHidden:YES animated:animated];
    

    相关文章

      网友评论

          本文标题:iOS - 界面偏移、状态栏导航栏显示隐藏

          本文链接:https://www.haomeiwen.com/subject/nxgbtktx.html