[英]How to create translucent (with content behind it) UITabBar
我已经将UITabBar子类化并覆盖了drawRect:方法,使其透明(并使其看起来像我需要的那样)。 我遇到的问题是添加到UITabBarController的视图没有覆盖整个屏幕但是在底部上方49个像素,所以即使我有透明的tabbar,我也看不到它背后的东西。
有没有正确的方法我可以在UITabBarController中设置UIView的大小来覆盖整个屏幕?
PS:我知道在tabbar后面显示内容并不是一个好主意。 我不想在那里展示任何内容,只是艺术,这是每个视图特有的,需要通过tabbar显示。
如果你想在UITabBar
后面有内容,我会看到两个选项:
不要使用UITabBarController
-这肯定会工作,因为只要你想,你可以定位的意见,也不是那么难实现它。
尝试在视图上关闭clipsToBounds
并将一些视图放在他的边界之外。
// 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或UITabBarController类别并设置它的Alpha
。
就像是 :-
@implementation UITabBarController (Translucent)
- (void)createImage
{
[self.tabBar setAlpha:0.1];
}
@end
您甚至可以在Drawrect中设置Alpha。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.