如何创建半透明(背后有内容)UITabBar [英] How to create translucent (with content behind it) UITabBar

查看:31
本文介绍了如何创建半透明(背后有内容)UITabBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经继承了 UITabBar 并覆盖了 drawRect: 方法以使其透明(并使其看起来像我需要的那样).我遇到的问题是添加到 UITabBarController 的视图没有覆盖整个屏幕,而是在底部上方 49 像素处结束,所以即使我有透明的标签栏,我也看不到它后面的东西.

I have subclassed UITabBar and overriden drawRect: method to make it transparent (and make it look like I need to). Problem I am having is that the view added to UITabBarController does not cover whole screen but ends 49 pixels above bottom, so even tho I have transparent tabbar, I can't see thing behind it.

是否有正确的方法可以在 UITabBarController 中设置 UIView 的大小以覆盖整个屏幕?

Is there proper way how I can set size of UIView inside UITabBarController to cover entire screen?

P.S.:我知道在标签栏后面显示内容不是一个好主意.我不想在那里显示任何内容,只是艺术,这是特定于每个视图的,需要通过标签栏可见.

P.S.:I know it is not good idea to show content behind tabbar. I do not want to show any content there, just art, that is specific to each View and needs to be visible through tabbar.

推荐答案

如果你想在 UITabBar 后面有内容,我看到两个选项:

If you want to have content behind the UITabBar, I see two options:

  • 不要使用 UITabBarController – 这肯定会起作用,因为您可以根据需要定位视图,而且实现它并不那么.

  • Don't use UITabBarController – This will definitely work, because you can position the views as you want and it is not so difficult to implement it.

尝试关闭视图上的 clipsToBounds 并将一些视图放在他的边界之外.

Try turning off clipsToBounds on the view and place some view out of his bounds.

// UIViewController contained in UITabBarController:
self.view.clipsToBounds = NO;
UIView *viewBehindTabBar = [[UIView alloc] init];
viewBehindTabBar.frame = CGRectMake(0, self.view.bounds.size.height,
                                    self.view.bounds.size.width, 49);
// autoresizing mask, background color, ...
[self.view addSubview:viewBehindTabBar];

这篇关于如何创建半透明(背后有内容)UITabBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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