我已经对 UITabBar
进行了子类化,我需要它是透明的。像这样:
我试过:[[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:79.0f/255.0 green:53.0f/255.0 blue:98.0f/255.0 alpha:0.6f]];
只是改变了条形的颜色,但条形仍然不透明。
请帮忙。我尝试了很多不同的方法,但都没有奏效。
最佳答案
试试这个
// 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];
这是结果
关于ios - 透明的 UITabBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27589797/