我注意到下面的代碼在MBProgressHUD(https://github.com/jdg/MBProgressHUD)爲什麼要用UIGraphicsPushContext/UIGraphicsPopContext
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
//do something
UIGraphicsPopContext();
}
我想知道的是,「推入背景」也是當前背景下,爲什麼作者在繪製前推的上下文。
的評論說:
使用UIGraphicsPushContext()& UIGraphicsPopContext()保存呼叫者圖形上下文w.r.t.該項目的drawRect:可以設置 (https://github.com/jdg/MBProgressHUD/commit/06d5bf88b9afffa7142e543606917033f157ba5e)
這是什麼意思