CGGradient in an CGPath

后端 未结 2 955
無奈伤痛
無奈伤痛 2020-12-16 07:20

Is it possible to draw a gradient in a path on the iPhone?

I\'m looking for a replacement of the mac os x method

-(void)drawInBezierPath:(NSBezierPa         


        
2条回答
  •  再見小時候
    2020-12-16 07:45

    Yes, I think so if I understand your question. It is a bit involved but here is a good example of doing it:

    http://cocoawithlove.com/2008/09/drawing-gloss-gradients-in-coregraphics.html

    This is done with Cocoa and not Cocoa Touch but it translates with everything bu NSColor. You have to use UIColor instead. Basically, you have to create a gradient function and then use:

    CGShadingCreateAxial()
    

    to determine the value of your gradient.

    Or are you wanting to have a line with a gradient?

提交回复
热议问题