mona
mona

Reputation: 67

How to call draw rect method to draw different shapes on a single button click?

I am having a button in UIViewController and i want to call drawRect method of UIView to draw different shapes on a button click of UIViewController.

Upvotes: 1

Views: 2737

Answers (2)

Jenn
Jenn

Reputation: 171

rokjarc's answer is correct and you should accept his answer, not mine. I'm just elaborating.

I suggest you view lectures 5 and 6 of the Stanford CS193P 2011 course.

http://itunes.apple.com/itunes-u/ipad-iphone-application-development/id473757255

Lecture 5 is mostly drawing, lecture 6 hooks up the drawRect to a slider.

edit credit to rokjarc

Upvotes: 1

Rok Jarc
Rok Jarc

Reputation: 18875

To answer first part of your question: how to call drawRect method.

You don't call this method directly, you simply call [view setNeedsDisplay];

As for the second part of your question. You don't tell drawRect what to draw via parameters - you override it and draw the objects you need by yourself.

You can find a nice tutorial here: An iPhone Graphics Drawing Tutorial using Quartz 2D

Upvotes: 1

Related Questions