0

I've been using some CAGradientLayers recently and I have notices some very ugly stepping in it. So I did some researching and found the possibility to use CALayers instead.

I'm very new to CoreGraphics and Quartz2D and I have no idea where to start with CALayers and drawing gradients.

Can somebody help me? Or lead me to some good examples?

Phil
  • 139
  • 1
  • 8

1 Answers1

2

The gradient layer does not dither, this is the reason for seeing some steps. But at the same time it is orders of magnitude faster because it draws directly on the GPU.

See Apple's Quartz 2D Programming Guide chapter on Gradients: https://developer.apple.com/library/mac/#documentation/graphicsimaging/conceptual/drawingwithquartz2d/dq_shadings/dq_shadings.html

You should look into CGGradientRef which you can use in a drawRect: or drawLayer:inContext: to draw any gradient.

Cocoanetics
  • 8,171
  • 2
  • 30
  • 57