+ (UIImage *)coloredImage:(UIImage *)image
:(UIColor *)color
{
UIGraphicsBeginImageContext(image.size);CGContextRef context = UIGraphicsGetCurrentContext();[color setFill];CGContextTranslateCTM(context, 0, image.size.height);
CGContextScaleCTM(context, 1.0, -1.0);CGContextSetBlendMode(context, kCGBlendModeColorBurn);
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
CGContextDrawImage(context, rect, image.CGImage);CGContextClipToMask(context, rect, image.CGImage);
CGContextAddRect(context, rect);
CGContextDrawPath(context, kCGPathFill);UIImage *coloredImage = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();return coloredImage;
}
:(UIColor *)color
{
UIGraphicsBeginImageContext(image.size);CGContextRef context = UIGraphicsGetCurrentContext();[color setFill];CGContextTranslateCTM(context, 0, image.size.height);
CGContextScaleCTM(context, 1.0, -1.0);CGContextSetBlendMode(context, kCGBlendModeColorBurn);
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
CGContextDrawImage(context, rect, image.CGImage);CGContextClipToMask(context, rect, image.CGImage);
CGContextAddRect(context, rect);
CGContextDrawPath(context, kCGPathFill);UIImage *coloredImage = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();return coloredImage;
}
解决方案 »
- 我有一段代码,在iphone 模拟器运行正常,但在macos 模拟器运行crash,请帮忙看下
- iphone模拟器960x640怎么开启使用
- iphone
- UICollectionView的选择问题
- UIApplicationMain的性能损耗
- 请问这个路径该如何写?
- 关于iOS8 Xcode 6 的界面设计问题
- windows能给ios程序添加字库吗?
- linker command failed with exit code 1 (use -v to see invocation)求解答,快哭了
- ios tableviewcell自适应行高
- 异步加载tableview图片
- MediaLibrary.mom
这段代码就是把你的 image 的像素 和 color 的值混合一下