views:

44

answers:

2
+1  Q: 

Quartz 2D Layers

I want to create 2 separate layers using quartz 2D. Can i handle there redraw methods separately? so that i can redraw 1 layer without redrawing the whole screen or other layers.

Is it possible? any code sample?

A: 

I'm coming from the Mac world. On the Mac, you'd create two overlapping views and deal with it that way. On the iPhone, I suspect you do the same: create two UIViews and then handle the two redraw methods independently. I believe overlapping views are fine on the iPhone (just as they are now on the Mac since 10.5).

Chris Suter
for both views drawRect will be separate? how to deal with it?
coure06
I don't understand what you mean. Just create two classes that have different drawRect methods (doing whatever you want) and then stick one instance of each into your Interface Builder file.
Chris Suter
+1  A: 

Yes, it's possible and easy to do. Use the QuartzViewController/QuartzView classes in Apple's QuartzDemo iPhone sample code to get started. Use subclasses if you want specialized behavior.

See here:

http://developer.apple.com/IPhone/library/samplecode/QuartzDemo/Introduction/Intro.html

Matt Martel