Andrew Andrew - 5 months ago 28
iOS Question

How do I add a radial gradient to a UIView?

I have a

which I want to have a radial gradient, and I'm wondering how to go about doing this?


To do this you need to drop down to Core Graphics and use CGContextDrawRadialGradient.

Similar Stack Overflow Questions

How can I draw a sector with radial gradient (iphone)

How to draw a gradient line (fading in/out) with Core Graphics/iPhone?

Other Resources

There's a tutorial showing how to draw icons with gradients on iOS here:

He's put the code on Github, complete with a UIView subclass that shows the (rather longwinded) way of making gradients using Core Graphics: