Reputation:
I develop a client app.
My question is: under the iPhone platform, how do I get a transparent region from UIImage?
Upvotes: 1
Views: 397
Reputation: 1748
create a mask layer to control the transparent region of the image.
see apple documentation here: https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/LayerVisProps.html#//apple_ref/doc/uid/TP40006074-SW21
Upvotes: 0
Reputation: 73588
You would need to use image masking. Try this -
UIImage *image = [UIImage imageNamed:@"yourImage.png"];
const float colorMasking[6] = {1.0, 1.0, 0.0, 0.0, 1.0, 1.0};
image = [UIImage imageWithCGImage: CGImageCreateWithMaskingColors(image.CGImage, colorMasking)];
Upvotes: 2