tags:

views:

164

answers:

1

I just need to know hot to create a CGLayer that has an image drawn to it. I am not completely understanding the documentation entirely. Thanks

+1  A: 

A while ago I posted a blog post on a similar topic, available here:

Drawing UIImages right side up using CoreGraphics

In that post, I show how to draw a UIImage so that's it's grayscale. Part of that includes creating a new layer with a gray colorspace (so it draws in shades of gray), and then extracting the CGContextRef from the CGLayer, pushing it to the context stack, drawing the UIImage, and then popping the context stack. The UIImage draws onto the topmost CGContextRef, which will be the context that corresponds to your CGLayer.

There are probably other ways to do this, but this is how I've done it in the past, and it's always worked great for me.

Dave DeLong