在iOS 8中完全透明的UITabBar
我试图让我的tabBar透明,我已经search,但我发现所有的文章导致部分和不完全透明tabBars和一些IOS 5等。
我想要做到这一点,如素描3所示:
什么是最简单的方法来完成这个?
我想这样做:
// Make the tabBar transparent self.tabBarController.tabBar.backgroundColor = [UIColor clearColor]; self.tabBarController.tabBar.translucent = YES;
但是结果并不完美:
真的很感谢帮助!:)
真诚的Erik
更新
// Make the tabBar transparent [[UITabBar appearance] setBarTintColor:[UIColor clearColor]]; self.tabBarController.tabBar.translucent = YES;
你尝试过barTintColor
吗?
[[UITabBar appearance] setBarTintColor:[UIColor clearColor]]; [[UITabBar appearance] setBackgroundImage:[UIImage new]];
这应该够了吧。
Swift 3.0
…在AppDelegate的didFinishLaunchingWithOptions中调用此代码
let tabBar = UITabBar.appearance() tabBar.barTintColor = UIColor.clear tabBar.backgroundImage = UIImage() tabBar.shadowImage = UIImage()
结果将是每个UITabBar的透明背景。
你需要inheritanceUITabBarController和viewdidload:
你应该把这个代码:
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;