Ios 透明阿巴尔

Ios 透明阿巴尔,ios,tabbar,Ios,Tabbar,我有一个子类uitabar,我需要它是透明的。像这样: 我尝试过:[[UITabBar外观]setbatintColor:[UIColor color withred:79.0f/255.0 green:53.0f/255.0 blue:98.0f/255.0 alpha:0.6f] 它只改变了条的颜色,但条仍然是不透明的 请帮忙。我尝试过很多不同的方法,但没有一种有效。这种设计是自iOS7以来的默认设计。试试这个: 试试这个 // The color you want the tab bar

我有一个子类
uitabar
,我需要它是透明的。像这样:

我尝试过:
[[UITabBar外观]setbatintColor:[UIColor color withred:79.0f/255.0 green:53.0f/255.0 blue:98.0f/255.0 alpha:0.6f]

它只改变了条的颜色,但条仍然是不透明的


请帮忙。我尝试过很多不同的方法,但没有一种有效。

这种设计是自iOS7以来的默认设计。试试这个:

试试这个

//  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];
这是结果

UITabBar.appearance().backgroundColor=UIColor.clearColor()
UITabBar.backgroundImage = UIImage()

以下是一个基于阿努帕·麦克休答案的解决方案

  • 为UITabBarController中的选项卡栏创建IBOutlet
  • 使用该选项可将选项卡栏设置为透明

    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
    

  • 没那么容易。我试过这个,但不够透明。还有其他想法吗?我在问题中加了一张照片。这就是我想要的。谢谢,这几乎就是我想要的。至少现在我知道该怎么做了。最后一个问题。我该怎么做才能让tableview在选项卡栏下滚动,但让我到达它的最后一个单元格?@KarolisRaišelis所以现在它在选项卡栏下滚动,但最后一个单元格在选项卡栏后面?您需要查看视图控制器的bottomLayoutGuide属性。这可能不起作用的原因有很多,但是如果您使用的是Interface Builder,那么请确保您的表/滚动视图位于最后面,iOS将仅在它位于最后面的视图时自动调整它。另外,请确保视图控制器的“automaticallyAdjustsScrollViewInsets”属性设置为“是”,以便为tableview中的最后一个部分添加页脚,使其按我所希望的方式工作。谢谢你的帮助!