Q:

Subclassing UIView to draw in Quartz

I'm trying to draw a figure in my iPhone application using Quartz 2D. I understand that I have to do this by subclassing UIView and overriding the drawRect function. I'm trying to follow this tutorial to do this but I can't get it to work.
It seems subclassing UIView does not create a .xib-file like the tutorial seem to imply. Subclassing UIViewController (I know this is wrong but I tried it anyway) does create a .xib-file but does not seem to have the drawRect-function.
Has anyone any experience in this, or knows what I'm doing wrong?
Thank you in advance,
Tobias Tovedal

A:

Create a UIView subclass and put your drawing code in its drawRect: method. You don't need a NIB file (why would you if you draw the view yourself?).
In a view controller, create an instance of your custom view class, set the view's frame and add it to the view controller's view with: [self.view addSubview:myCustomView];.
There is no step 3.

