如何以编程方式获取tabbar的高度? [英] How to get the height of the tabbar programmatically?

查看:82
本文介绍了如何以编程方式获取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的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆