简体   繁体   中英

Bar section in iOS is extended unnecessarily

In the image shared, the orange section is the bar section , which is having unnecessary height, I am not able to resolve this issue by myself.

the views are like this

Parent Controller = View Controller Child views = green view, black tableview

Please help to correct the height of the orange bar.

图片

Seems like you have enabled prefersLargeTitles .

Make it false in your viewWillAppear()

self.navigationController?.navigationBar.prefersLargeTitles = false

You can also disable it from the storyboard.

Select your Navigation Controller -> Navigation Bar -> Uncheck prefers large titles

在此处输入图片说明

it seems like you're using the largeTitles on the navigationBar ,

var prefersLargeTitles: Bool { get set }

When this property is set to true, the navigation bar allows the title to be displayed out-of-line and using a larger font. The navigation item used to build the bar must specify whether it wants its title displayed in the large or small format. Use the largeTitleDisplayMode property to configure the title's appearance. When the property is set to false, the navigation bar displays the title inline with the other bar button items.

try to disable it by:

navigationController?.navigationBar.prefersLargeTitles = false

or you can do this as well:

navigationItem.largeTitleDisplayMode = .never

hope this helps:)

https://developer.apple.com/documentation/uikit/uinavigationbar/2908999-preferslargetitles

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