ios 如何以编程方式获取 UINavigationBar.navigationItem 的高度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5781553/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 19:43:01  来源:igfitidea点击:

How do I obtain the height of UINavigationBar.navigationItem programmatically?

iosuinavigationitem

提问by ChrisP

I am creating a custom UIToolbarto use as a UIViewin the UINavigationBar.navigationitem.titleViewproperty. I would like to size the toolbar height to that of the .navigationitem by obtaining the current height of the .navigationitem rather than hard code it. Is there a way to obtain the height value?

我创建一个自定义UIToolbar为使用UIViewUINavigationBar.navigationitem.titleView属性。我想通过获取 .navigationitem 的当前高度而不是硬编码来将工具栏高度调整为 .navigationitem 的高度。有没有办法获得高度值?

回答by AbeEstrada

Not sure if this is what you need.

不确定这是否是您所需要的。

self.navigationController.navigationBar.frame.size.height

self.navigationController.navigationBar.frame.size.height