Completely transparent UITabBar in iOS 8

后端 未结 3 862
后悔当初
后悔当初 2020-12-24 14:43

I\'m trying to make my tabBar transparent, I\'ve searched but all I found was articles resulting in partly and not fully transparent tabBars and some were for IOS 5, etc.

相关标签:
3条回答
  • 2020-12-24 15:18

    Swift 3.0

    ... call this code in the AppDelegate's didFinishLaunchingWithOptions

    let tabBar = UITabBar.appearance()
    tabBar.barTintColor = UIColor.clear
    tabBar.backgroundImage = UIImage()
    tabBar.shadowImage = UIImage()
    

    The result will be a transparent background for every UITabBar.

    0 讨论(0)
  • 2020-12-24 15:26

    You need to subclass the UITabBarController and in the viewdidload: you should put this code:

    CGRect rect = CGRectMake(0, 0, 1, 1);
    UIGraphicsBeginImageContextWithOptions(rect.size, NO, 1.0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
    CGContextFillRect(context, rect);
    UIImage *transparentImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    [self.tabBar setBackgroundImage:transparentImage];
    [self.tabBar setShadowImage:transparentImage];    
    //    self.tabBar.alpha = 0.0;
    
    0 讨论(0)
  • 2020-12-24 15:33

    Have you tried the barTintColor?

    [[UITabBar appearance] setBarTintColor:[UIColor clearColor]];
    [[UITabBar appearance] setBackgroundImage:[UIImage new]];
    

    That should do the trick.

    0 讨论(0)
提交回复
热议问题