iOS开发 设置tabbar颜色

通过设置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;

你可能感兴趣的:(iOS开发 设置tabbar颜色)