ios 改变系统UITabbar 和UINavigaitonba

2017-03-07  本文已影响0人  高先生Devin

1. //改变标签栏横线颜色

NSArray  *tabArray=self.tabBarController.tabBar.subviews;

for ( id obj  in tabArray) {

if ([obj isKindOfClass:[UIImageView class]]) {

UIImageView *imageView=(UIImageView *) obj;

imageView.backgroundColor=View_ToolBar;

}

}

2.//改变导航条横线颜色

//给imgaeview 添加一个类别

+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size

{

CGRect rect = CGRectMake(0, 0, size.width, size.height);

UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context,

color.CGColor);

CGContextFillRect(context, rect);

UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return img;

}

//调用

[[UINavigationBar appearance] setShadowImage:[UIImage imageWithColor:tabBar_line size:CGSizeMake(kDeviceWidth, 1)]];

上一篇 下一篇

猜你喜欢

热点阅读