0
在一些代碼段核心圖形狀態管理
- (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
CGContextSetFillColorWithColor(ctx, [[UIColor darkTextColor] CGColor]);
UIGraphicsPushContext(ctx);
...
當前填充顏色被設置,那麼狀態被壓入堆棧。 其他片段:
- (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
UIGraphicsPushContext(ctx);
[[UIColor darkTextColor] set];
...
哪種方式正確?在狀態管理方面,這兩種方法CGContextSetFillColorWithColor
和UIColor set
之間有什麼區別?