‘invalid context 0x0’ error when using CGContext* functions

后端 未结 1 1710
青春惊慌失措
青春惊慌失措 2020-12-06 19:34
/*  Adding the Path */
UserGraphBuff = UIGraphicsGetCurrentContext();

CGContextSetRGBStrokeColor(UserGraphBuff,5,10,0,1);
CGContextSetLineWidth(UserGraphBuff, 2 );
         


        
相关标签:
1条回答
  • 2020-12-06 20:23

    For your code to work, it needs to be executed in the drawRect method of your UIView subclass (and you don't call drawRect directly - this is called by the OS when it needs the UIView to render itself). You're presumably trying to run this code from a touch event or from viewDidLoad or something like that.

    0 讨论(0)
提交回复
热议问题