用UIBezierPath画图,
UIBezierPath * strokePath = [UIBezierPathbezierPath];
strokePath = [UIBezierPathbezierPathWithRect:CGRectMake(0,0,self.frame.size.width*pathFloat,self.frame.size.height)];
[strokePath closePath];
[strokePath stroke];
当执行stroke方法时,报错:
<Error>: CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
查看文档,
This method automatically saves the current graphics state prior to drawing and restores that state when it is done, so you do not have to save the graphics state yourself.
current graphics state:需要当前graphics state,所以报错。
- (void)drawRect:(CGRect)rect
方法里后,问题解决。