Create a simple app, and can't do it without an error
I don't really know why bg.drawInRect doesn't cause an error when player.drawInRect causing? And the problem is that image doesn't drawing/redrawing when we change coordinates
Sep 16 22:13:16 imac-admin.lan Letalka_drawrect[804] : CGContextRestoreGState: 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.
You need to start your timer outside your
drawRect
call;didMoveToSuperview
might be a good place, but it depends on what you're trying to accomplish. Then, intimerRedraw
, callsetNeedsDisplay()
to trigger a re-draw.I highly recommend reading Apple's Drawing and Printing Guide for iOS, it explains everything you need to know to get started with doing custom drawing in iOS.