带有透明边框的UIImage面具

时间:2013-04-15 09:00:08

标签: iphone ios objective-c

我正在使用此方法来屏蔽UIImage

UIImage *inputImage = [UIImage imageName:@"inputImage.png"];
CGImageRef maskRef = [UIImage imageNamed:@"mask.png"].CGImage; 

CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
                                    CGImageGetHeight(maskRef),
                                    CGImageGetBitsPerComponent(maskRef),
                                    CGImageGetBitsPerPixel(maskRef),
                                    CGImageGetBytesPerRow(maskRef),
                                    CGImageGetDataProvider(maskRef), NULL, false);

CGImageRef masked = CGImageCreateWithMask([inputImage CGImage], mask);
CGImageRelease(mask);

UIImage *maskedImage = [UIImage imageWithCGImage:masked];

CGImageRelease(masked);

这是掩码图像:

enter image description here

问题是,当我屏蔽图像边框为黑色时,可以使边框透明吗?

0 个答案:

没有答案