Istnieją dwie metody drawRect:CGContextSaveGState vs UIGraphicsPushContext
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
// do drawing here
CGContextRestoreGState(context);
}
I
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
// do drawing here
UIGraphicsPopContext();
}
UIGraphicsPushContext/UIGraphicsPopContext są od UIKit podczas CGContextSaveGState/CGContextRestoreGState są od CoreGraphics.
Pytania: Jaka jest różnica między tymi metodami? Którego lepiej użyć? Czy istnieją przykłady udowodnienia jednej metody lepiej niż inne i vice versa?