改变图片颜色
2014-04-24 13:55
183 查看
- (UIImage *)imageWithColor:(UIColor *)color
{
UIGraphicsBeginImageContextWithOptions(self.size, NO, self.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;
}
{
UIGraphicsBeginImageContextWithOptions(self.size, NO, self.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;
}
相关文章推荐
- Android改变图片颜色的自定义控件
- swift 改变图片颜色
- 动态改变 图片的背景颜色
- 使用tintColor改变图片的颜色
- iOS开发笔记--使用blend改变图片颜色
- Android 使用ColorMatrix改变图片颜色
- android 改变ImageView的图片非透明颜色变成某一种特定的颜色
- 改变ListBox中Items的颜色,并且为ListBox中的项目添加图片。
- silverlight 修改image图片,改变label字体颜色
- PorterDuff改变图片颜色
- android 改变图片 字体颜色
- 纯css svg 改变图片颜色 ios android 小程序
- 使用asp.net改变图片颜色如灰色的变成彩色
- Android改变图片背景颜色tint(着色)或 backgroundTint
- Drawable 添加过滤色,改变图片颜色
- iOS中使用blend改变图片颜色
- iOS中使用blend改变图片颜色
- iOS tabBar颜色渲染和改变选中时图片
- VC对话框加载图片、改变背景颜色、画图、显示隐藏控件
- 对鼠标移到图片上及离开图片时,图片背景颜色改变的JS实现