CGContextを保存および復元して、2回目の大量の描画計算を回避しようとすると、エラーが発生します<Error>: CGGStackRestore: gstack underflow
。
私は何が間違っているのですか?これを行う正しい方法は何ですか?
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
if (initialized) {
CGContextRestoreGState(context);
//scale context
return;
}
initialized = YES;
//heavy drawing computation and drawing
CGContextSaveGState(context);
}