解决 iOS 11 webview 顶部空白条的问题

- (void)viewDidLoad {

    [super viewDidLoad];

    self.automaticallyAdjustsScrollViewInsets=NO;


    webView = [[UIWebView alloc] initWithFrame:self.view.frame];

    [self.view addSubview:webView];


    NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];

    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];

    [webViewloadRequest:request];


    //解决 iOS 11 屏幕顶部显示不全

    if(@available(iOS11.0, *)) {

        webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

    }else{

        // Fallback on earlier versions

    }

}

你可能感兴趣的:(解决 iOS 11 webview 顶部空白条的问题)