/* Adding the Path */
UserGraphBuff = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(UserGraphBuff,5,10,0,1);
CGContextSetLineWidth(UserGraphBuff, 2 );
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.