项目中是使用UITabbarController 因此改变UITabbar的分割线代码如下:
一般美工会提供切图或者提供分割线颜色的色值, 今天我们就用色值来创建图片
//改变tabbar 线条颜色
CGRect rect = CGRectMake(0, 0, ScreenWidth, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,
RGB(253, 125, 83).CGColor);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.tabBar setShadowImage:img];
[self.tabBar setBackgroundImage:[[UIImage alloc]init]];注意:
self.tabBar setShadowImage:img];
[self.tabBar setBackgroundImage:[[UIImage alloc]init]];
缺一不可,否则将无法改变分割线颜色
本文介绍了如何在使用UITabbarController的iOS项目中,根据美工提供的色值改变Tabbar的分割线颜色。通过设置shadowImage和backgroundImage实现这一效果。

3458

被折叠的 条评论
为什么被折叠?



