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
How do I obtain the height of UINavigationBar.navigationItem programmatically?
提问by ChrisP
I am creating a custom UIToolbar
to use as a UIView
in the UINavigationBar.navigationitem.titleView
property. 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
为使用UIView
的UINavigationBar.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