Undo
Undo

Reputation: 25687

Draw UIBezierPath That Fades at Ends (Gradient)

I am trying to draw a UIBezierPath that fades out at both ends - from alpha 0 to 1 then back to 0. I basically want to be able to draw a gradient in a UIBezierPath from within drawRect.

EDIT: Here's the effect I'm trying to achieve:

enter image description here

Upvotes: 8

Views: 1509

Answers (1)

Fabiano Francesconi
Fabiano Francesconi

Reputation: 1780

What about using -strokeWithBlendMode:alpha:?

In combination with some sort of loop that keeps incrementing/decrementing the alpha value until you reach the 1 (and the increment determines the length of the "faded" segment) should work.

See here

Upvotes: 1

Related Questions