根据颜色获取图片

+ (UIImage *)imageWithColor:(UIColor *)color{
    // 描述矩形
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    // 开启位图上下文
    UIGraphicsBeginImageContext(rect.size);
    // 获取位图上下文
    CGContextRef context = UIGraphicsGetCurrentContext();
    // 使用color演示填充上下文
    CGContextSetFillColorWithColor(context, [color CGColor]);
    // 渲染上下文
    CGContextFillRect(context, rect);
    // 从上下文中获取图片
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    // 结束上下文
    UIGraphicsEndImageContext();
    
    return theImage;
}

 

//设置tabBar的文字颜色  

self.tabBar.tintColor = [UIColor colorWithRed:254/255.0 green:202/255.0 blue:11/255.0 alpha:1];

 

 

posted on 2016-05-10 16:50  玉思盈蝶  阅读(313)  评论(0编辑  收藏  举报

导航