简体   繁体   中英

Space between navigationbar and WKWebview IOS Swift4

在此处输入图片说明 在此处输入图片说明

Hi I am using NavigationBar with search but in when i click on button hiding navigation search and showing webview but it is showing space between both.

if #available(iOS 11.0, *) {
    self.navigationItem.searchController = nil
 } else {
    mainTableView.tableHeaderView = nil
 }

I am using above code to hide the searchbar it is hiding but the space of the navigation bar is not removing.

 self.navigationController?.setNavigationBarHidden(true, animated: animated)

我认为您只隐藏了搜索栏,因此您可能也必须隐藏导航栏,因此请尝试上面的代码

If you are using AutoLayout, this behaviour is due to safe area layout guides. For device with notch, top constraint calculates distance from Safe Area(starting from notch). To solve this, go to storyboard -> select WebView -> select top constraint. You will see few options related to constraint on Size inspector. Change Second Item to SuperView instead of Safe Area.

尺寸检查器的屏幕截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM