ios - CAGradientLayer not draw the gradient correctly -


i use cashapelayer draw circle , set mask of cagradientlayer, here code:

cashapelayer *circleshapelayer = [cashapelayer new]; // draw circle path code here...  cagradientlayer *gradientlayer = [cagradientlayer layer]; gradientlayer.colors = @[(__bridge id)[uicolor whitecolor].cgcolor,                          (__bridge id)[uicolor clearcolor].cgcolor]; // self here means uiview gradientlayer.mask = circleshapelayer; gradientlayer.frame = self.bounds; [self.layer addsublayer:gradientlayer]; 

when run app, display gradient circle, gradient strange.

what want circle @ start point, color white , @ end point color clear color, should this:

enter image description here

but color of circle in simulator screen is:

enter image description here

the color symmetric.

i think problem not set gradientlayer.colors correctly, how can fix it?

cagradientlayer can not paint gradient along arc. on other hand, mask layer's frame small gradient layer's frame see clear color


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -