您的位置:首页 > 移动开发 > IOS开发

改变图片颜色

2014-04-24 13:55 183 查看
- (UIImage *)imageWithColor:(UIColor *)color

{

UIGraphicsBeginImageContextWithOptions(self.size, NOself.scale);

CGContextRefcontext = UIGraphicsGetCurrentContext();

CGContextTranslateCTM(context, 0, self.size.height);

    CGContextScaleCTM(context, 1.0, -1.0);

CGContextSetBlendMode(context, kCGBlendModeNormal);

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

    CGContextClipToMask(context, rect, self.CGImage);

    [color setFill];

    CGContextFillRect(context, rect);

UIImage*newImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

    return newImage;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  图片 ios