我需要在UIImage上添加可以撤消的像素化矩形圖層。 Just like this.。ios圖像上的像素化圖層
我用這個代碼,但它不是做同樣的事情,因爲我需要
CALayer *maskLayer = [CALayer layer];
CALayer *mosaicLayer = [CALayer layer];
// Mask image ends with 0.15 opacity on both sides. Set the background color of the layer
// to the same value so the layer can extend the mask image.
mosaicLayer.contents = (id)[img CGImage];
mosaicLayer.frame = CGRectMake(0,0, img.size.width, img.size.height);
UIImage *maskImg = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"mask" ofType:@"png"]];
maskLayer.contents = (id)[maskImg CGImage];
maskLayer.frame = CGRectMake(100,150, maskImg.size.width, maskImg.size.height);
mosaicLayer.mask = maskLayer;
[imageView.layer addSublayer:mosaicLayer];
UIGraphicsBeginImageContext(imageView.layer.bounds.size);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *saver = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
有沒有內置過濾器通過蘋果的iOS?請指引我感謝
我想在圖像上使用圖層是否支持? – Ali 2015-03-03 05:22:31
此答案適用於全圖像素化。你不能通過使用這個 – Ali 2015-03-03 12:19:53
@Ali在圖像上繪製像素化的文本文件只需裁剪圖像,像素化它,然後將其放回原始圖像上? – rounak 2015-03-03 15:26:10