如何以编程方式获取tabbar的高度?

编程入门 行业动态 更新时间:2024-10-24 01:54:42
本文介绍了如何以编程方式获取tabbar的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我发现UITabBar的高度是49px(或50px,取决于来源)。

I've found out that the height of a UITabBar is 49px (or 50px, depending on the source).

因为我不喜欢使用它我的代码中有很多硬编码的值我想知道是否可以通过编程方式检索tabbar的高度。

Because I don't like to use too much hard-coded values in my code I was wondering if it is possible to retrieve the height of the tabbar programmatically.

亲切的问候, Niels R.

Kind regards, Niels R.

PS:我问的原因是因为我有一个视图控制器(带有包含文本字段的列表视图),它只是由navigationcontroller推送( pushViewController)或呈现为模态(presentModalViewController)。一旦键盘出现,视图的大小就会减小,但我必须考虑到只有在按下视图控制器时才能看到标签栏,而不是以模态显示。

PS: The reason I'm asking is because I have a view controller (with a list view containing text fields) that is either simply pushed by the navigationcontroller (pushViewController) or presented as a modal (presentModalViewController). As soon as the keyboard show up, the size of the view is reduced, but I have to take into account that the tabbar is only visible when the view controller is pushed and not presented as a modal.

推荐答案

我不完全理解您的PS,但您可以这样做:

I don't totally understand your P.S., but you can do:

tabBarController?.tabBar.frame.size.height

更多推荐

如何以编程方式获取tabbar的高度?

本文发布于:2023-11-26 00:08:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631882.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:高度   方式   tabbar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!