iOS_分栏控制器


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;

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值