How to draw on UIView

Go To


Possible Duplicate:
Subclassing UIView to draw in Quartz

Hello i am searching good example how to draw something on UIView, UIScrollView ... using QuartzCore.

For first try i want to draw a triangle or even a line on some view. Is it possible this implement in UIVIewController ?


2012-04-04 05:27
by Streetboy


The easiest way is to subclass a UIView, have your UIViewController add an instance of the subclass as a visible sub view, and call setNeedsDisplay on it. Then, when the drawRect method of your UIView subclass gets called, do your quartz drawing on the context given.

2012-04-04 05:43
by hotpaw2


This can be an excellent start up tutorial for Quartz core

Quartz Core Sample From Apple

This includes all basic drawings. No doubt you will need to optimize that.

2012-04-04 05:34
by DivineDesert