1
我已經保存了一堆CGContextRefs,並且我想在我的UIView的drawRect部分中繪製所有這些。我怎樣才能做到這一點?如何繪製多個CGContextRefs到-drawRect?
我已經保存了一堆CGContextRefs,並且我想在我的UIView的drawRect部分中繪製所有這些。我怎樣才能做到這一點?如何繪製多個CGContextRefs到-drawRect?
這裏有一種方法:
- (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);
}
謝謝。我一直在閱讀關於圖形狀態。我只是試圖保存個別的筆觸,所以保存和恢復圖形狀態是一個更快的方法來做到這一點? – RexOnRoids 2009-09-08 05:26:27
如何在-drawRect中繪製生成的圖像? – RexOnRoids 2009-09-08 05:43:01
就是這樣。最終的圖像被繪製在提供給drawRect的矩形中。 – mahboudz 2009-09-08 18:16:30