I’m new to iPhone programming and can’t figure out how to use Core Graphics. The code I am testing with is:
- (void)drawRect:(CGRect)rect{
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextClearRect(ctx, rect);
CGContextSetRGBStrokeColor(ctx, 255, 255, 0, 1);
CGContextStrokeRect(ctx, CGRectMake(195, 195, 60, 60)); }
I put it in the ViewController.m file on a default View based application but nothing happens when the application is run.
drawRectis a method of theUIViewclass, notUIViewController. You need to create your ownUIViewsubclass and implement that one’sdrawRect. To actually use the class, just set the class name in thexibfile that comes with the view.