Non*_*ain 9 cocoa-touch core-graphics mask uikit ios
好吧使用coregraphics,我正在构建一个稍后将用于CGContextClipToMask操作的图像.它看起来像下面这样:
UIImage *eyes = [UIImage imageNamed:@"eyes"];
UIImage *mouth = [UIImage imageNamed:@"mouth"];
UIGraphicsBeginImageContext(CGSizeMake(150, 150));
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0, 0, 0, 1);
CGContextFillRect(context, bounds);
[eyes drawInRect:bounds blendMode:kCGBlendModeMultiply alpha:1];
[mouth drawInRect:bounds blendMode:kCGBlendModeMultiply alpha:1];
// how can i now get a CGImageRef here to use in a masking operation?
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
现在,正如你在评论中看到的那样,我想知道我是如何实际使用我建立的图像的.我在这里使用核心图形而不仅仅是构建UIImage的原因是我正在创建的透明度非常重要.如果我只是从上下文中获取UIImage,当它被用作掩码时,它将仅适用于所有内容......更重要的是,使用此方法使用部分透明掩码会有任何问题吗?
Nic*_*ico 14
CGImageRef result = CGBitmapContextCreateImage(UIGraphicsGetCurrentContext());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5305 次 |
| 最近记录: |