项目中是使用UITabbarController 因此改变UITabbar的分割线代码如下
由于美术没提供图片,所以自己创建了个图片
//改变tabbar 线条颜色
CGRect rect = CGRectMake(, , ScreenWidth, );
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,
RGB(, , ).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]];
缺一不可,否则将无法改变分割线颜色
以上仅本人学习笔记,用于日后方便查阅