擴展上面的答案創建具有完全不透明的中心和邊緣的口罩應融入對透明度然後用下面的代碼來掩蓋
- (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage {
CGImageRef imgRef = [image CGImage];
CGImageRef maskRef = [maskImage CGImage];
CGImageRef actualMask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
CGImageGetBitsPerComponent(maskRef),
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);
CGImageRef masked = CGImageCreateWithMask(imgRef, actualMask);
return [UIImage imageWithCGImage:masked];
}
是對邊緣漸變到白色的要求或爲他們褪色背景/透明? – 2012-01-17 23:15:06
淡入背景/透明將是最好的。謝謝 – Clarence 2012-01-18 04:02:40