[英]Transparent UITabBar
I have subclassed UITabBar
and I need it to be transparent. 我已经将
UITabBar
子类化了,我需要它是透明的。 Like This: 像这样:
I have tried : [[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:79.0f/255.0 green:53.0f/255.0 blue:98.0f/255.0 alpha:0.6f]];
我试过了:
[[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:79.0f/255.0 green:53.0f/255.0 blue:98.0f/255.0 alpha:0.6f]];
It only changed The bar's color, but The bar is still not transparent. 它只改变了条形图的颜色,但条形图仍然不透明。
Please help. 请帮忙。 I have tried lots of different methods, but none of them worked.
我尝试过很多不同的方法,但都没有。
Try this 尝试这个
// The color you want the tab bar to be
UIColor *barColor = [UIColor colorWithRed:79.0f/255.0 green:53.0f/255.0 blue:98.0f/255.0 alpha:0.6f];
// Create a 1x1 image from this color
UIGraphicsBeginImageContext(CGSizeMake(1, 1));
[barColor set];
UIRectFill(CGRectMake(0, 0, 1, 1));
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Apply it to the tab bar
[[UITabBar appearance] setBackgroundImage:image];
Here's the result 这是结果
Here is a solution based on AnupamChugh's answer 这是基于AnupamChugh的答案的解决方案
Use that to set the tab bar as transparent 使用它将标签栏设置为透明
class AppTabBarController: UITabBarController { @IBOutlet weak var mTabBar: UITabBar! override func viewDidLoad() { super.viewDidLoad() mTabBar.backgroundColor = UIColor.clear mTabBar.backgroundImage = UIImage() mTabBar.shadowImage = UIImage() // removes the border
UITabBar.appearance().backgroundColor=UIColor.clearColor()
UITabBar.backgroundImage = UIImage()
This kind of design is the default since iOS7. 这种设计是iOS7以来的默认设计。 Try this:
尝试这个:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.