How to create translucent (with content behind it) UITabBar

狂风中的少年 提交于 2019-12-05 21:33:04

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

  • 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.

  • 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];
    

You can simply create a category of UITabBar or UITabBarController and set It's Alpha.

Something Like :-

@implementation UITabBarController (Translucent)
- (void)createImage
{
     [self.tabBar setAlpha:0.1];
}
@end

You can set Alpha even in Drawrect .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!