objective c - Masking a sublayer gradient to CAShapeLayer -


i have cashapelayer bezierpathwithovalinrect. want make gradient layer fill circle, @ moment fills whole frame.

how do this?

cashapelayer *layerinsides = [cashapelayer layer]; layerinsides.path = [uibezierpath bezierpathwithovalinrect:rectfrom(frameinsides)].cgpath;  cagradientlayer *gradientlayer = [cagradientlayer layer]; gradientlayer.frame = layerinsides.frame; gradientlayer.colors = @[(id)[uicolor colorwithred:1 green:0 blue:0 alpha:1].cgcolor, (id)[uicolor colorwithred:0 green:0 blue:0 alpha:1].cgcolor]; gradientlayer.locations = @[@0.0, @1]; gradientlayer.cornerradius = self.layer.cornerradius; [layerinsides addsublayer:gradientlayer]; 

enter image description here

instead of adding content shape sublayer need set cashapelayer mask colored layer:

gradientlayer.mask = layerinsides; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -