【发布时间】:2016-05-29 21:45:12
【问题描述】:
我正在尝试以编程方式将白色 imageView.image 变成不同的颜色。轮廓当前为白色。
我正在尝试将this solution 与 CIFilter 一起使用,但图像根本没有出现。
这是粘贴的代码供参考:
- (UIImage *) filterImage: (CIImage *)beginImage color: (UIColor *) color{
CIImage *output = [CIFilter filterWithName:@"CIColorMonochrome" keysAndValues:kCIInputImageKey, beginImage, @"inputIntensity", [NSNumber numberWithFloat:1.0], @"inputColor", [[CIColor alloc] initWithColor:color], nil].outputImage;
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cgiimage = [context createCGImage:output fromRect:output.extent];
UIImage *newImage = [UIImage imageWithCGImage:cgiimage];
CGImageRelease(cgiimage);
return newImage;
}
【问题讨论】: