如何将多个CGContextRef绘制为-drawRect?

时间:2009-09-08 04:39:32

标签: iphone uikit uiview paint cgcontext

我已经保存了一堆CGContextRefs,我想在我的UIView的drawRect部分中绘制所有这些。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

这是一种方式:

- (void)drawRect:(CGRect)rect {
    CGImageRef newImg = CGBitmapContextCreateImage(ctx1);
    [[UIImage imageWithCGImage:newImg] drawInRect:rect];
    CGImageRelease(newImg);
    CGImageRef newImg = CGBitmapContextCreateImage(ctx2);
    [[UIImage imageWithCGImage:newImg] drawInRect:rect];
    CGImageRelease(newImg);
}