iOS 11 SearchBar in NavigationBar

后端 未结 8 1875
陌清茗
陌清茗 2020-12-12 12:44

With iOS 11 Apple has redesigned the UISearchBar by making the corners rounder and the height bigger. Adding a UISearchBar to the navigationBar is pretty simple by just sett

8条回答
  •  情深已故
    2020-12-12 13:11

    Make a summary in iOS 14+

    First to fix push cause extra height:

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        navigationController?.view.setNeedsLayout() // force update layout
        navigationController?.view.layoutIfNeeded() // to fix height of the navigation bar
    }
    

    Second to fix pop to origin height:

    extendedLayoutIncludesOpaqueBars = true
    

    All above code set in the controller with search bar.

提交回复
热议问题