我使用UIGraphicsPushContext推上下文中的drawRect像這樣做:環境中使用UIGraphicsPushContext不顯示渲染圖像
- (void)drawRect:(CGRect)rect {
// Create Bitmap Graphics Context
UIContextRef ctxt = //blah blah;
// Push the custom context in the graphics stack
UIGraphicsPushContext(ctxt);
// Draw Stuff
// Get Image from custom context
}
我的問題是圖像不顯示在屏幕上(上圖),但我可以確認我已成功繪製上下文,因爲從上下文中檢索的圖像顯示的圖像與我打算繪製的圖像相似。
我想實現的是取代我的UIGraphicsGetCurrentContext()(它工作並顯示圖像)的調用,並使用(推送)我可以使用的自定義上下文。
我在這裏錯過了什麼嗎?謝謝!
究竟是什麼,你要完成?如果你想繪製到視圖,你應該使用UIGraphicsGetCurrentContext()。 – loomer 2010-10-26 13:32:47
我想將它繪製在自定義上下文中,而不是從drawRect給予我的上下文,以便我可以控制位圖內存並重用相同的上下文。 – LaN 2010-10-27 02:20:09