好的使用coregraphics,我正在建立一个图像,稍后将在CGContextClipToMask
操作中使用。它看起来像下面这样:如何从Context-Drawn Images获取CGImageRef?
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();
现在,你可以通过评论看到,我想知道我怎么竟要使用我已经建立起来的形象。之所以我在这里使用核心图形,而不是仅仅构建UIImage,是因为我创建的透明度非常重要。如果我只是从上下文中获取UIImage,当它用作掩码时,它将适用于所有内容...更重要的是,使用此方法使用部分透明的掩码会有什么问题吗?
[Drawing into CGImageRef]的可能重复(http://stackoverflow.com/questions/4257043/drawing-into-cgimageref) – 2011-12-26 17:00:27