iOS开发 设置tabbar颜色

2020-12-15  本文已影响0人  小y想吃糖

通过设置backgroundimage

- (UIImage *)createImageWithColor:(UIColor *)color {

    CGRectrect=CGRectMake(0.0f,0.0f,1.0f,1.0f);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [color CGColor]);

    CGContextFillRect(context, rect);

    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    returntheImage;

}

在viewdidload中加上

//Tabbar的上横线

[[UITabBar appearance] setShadowImage:[selfcreateImageWithColor:[UIColor orangeColor]]];

//背景图片

        [[UITabBar appearance] setBackgroundImage:[selfcreateImageWithColor:kColorWith(0,0,0,.65)]];

        self.tabBar.backgroundColor = [UIColor clearColor];

    //设置为半透明

        self.tabBarController.tabBar.translucent = YES;

上一篇下一篇

猜你喜欢

热点阅读