1. ###iOS_分栏控制器点击背景
CGSize indicatorImageSize = CGSizeMake(self.tabBar.bounds.size.width / KTabItemCounts, self.tabBar.bounds.size.height);
CGSize indicatorImageSizeBack = CGSizeMake(self.tabBar.bounds.size.width, self.tabBar.bounds.size.height);
UIColor *selectedColor = KCplUIColor_RGBA(235, 249, 255, 1);
UIColor *backGroundColor = KCplUIColor_RGBA(249, 253, 255, 0.5);
_imageTabBarItemSelected = [self drawSelectedTabBarItemBackgroundImageWithSize:indicatorImageSize WithColor:selectedColor];
_imageTabBarItemBack = [self drawTabBarItemBackgroundImageWithSize:indicatorImageSizeBack WithColor:backGroundColor];
[self.tabBar setBackgroundImage:_imageTabBarItemBack];
self.tabBar.selectionIndicatorImage = _imageTabBarItemSelected;
self.tabBar.barTintColor = [UIColor colorWithRed:255/255.0 green:252/255.0 blue:251/255.0 alpha:1];
self.tabBar.shadowImage = [[UIImage alloc]init];
-(UIImage *)drawTabBarItemBackgroundImageWithSize:(CGSize)size WithColor:(UIColor *)color{
//准备绘图环境
UIGraphicsBeginImageContext(size);
CGContextRef ctx = UIGraphicsGetCurrentContext(); //上下文
CGContextSetFillColorWithColor(ctx, color.CGColor);
//CGContextSetRGBFillColor(ctx, 243/255.0,249/255.0,252/255.0,1); //图片颜色 193 225 238
CGContextFillRect(ctx, CGRectMake(0, 0, size.width, size.height));
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
//结束绘图
UIGraphicsEndImageContext();
return img;
}
-(UIImage *)drawSelectedTabBarItemBackgroundImageWithSize:(CGSize)size WithColor:(UIColor *)color{
//准备绘图环境
UIGraphicsBeginImageContext(size);
CGContextRef ctx = UIGraphicsGetCurrentContext(); //上下文
CGContextSetFillColorWithColor(ctx, color.CGColor);
//CGContextSetRGBFillColor(ctx, 243/255.0,249/255.0,252/255.0,1); //图片颜色 193 225 238
CGContextFillRect(ctx, CGRectMake(0, 0, size.width, size.height));
CGMutablePathRef path = CGPathCreateMutable();
CGRect rectangle = CGRectMake(0, 0, size.width, size.height); //指定矩形
CGPathAddRect(path,NULL,rectangle); //将矩形添加到路径中
CGContextAddPath(ctx, path);
[KCplUIColorFromRGB(0xC1E1EE) setStroke];
CGContextSetLineWidth(ctx,2.0f);
CGContextDrawPath(ctx, kCGPathFillStroke);
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
//结束绘图
UIGraphicsEndImageContext();
return img;
}