ios - CAGradientLayer with Angle -
i drawing cgpath
not rectangle or square,and adding cgpath
cashapelayer
. cashapelayer
's frame getting cgpath
using cgpathgetboundingbox(path)
. rectangle or square. want set gradient color layer path not rectangle or square not spreading gradient color equally in whole cgpath
. there way set gradient color cgpath or how can set gradient color angle?
please refer screen shot understand situation. here white color indicates frame of cgpath
, green colour, our drawn cgpath
. @ bottom of cgpath
can see white gradient colour not distributed equally in cgpath
.
the start , end points of linear gradient specified in points relative whole size of layer, (0,0) @ top left , (1,1) @ bottom right.
therefore, make linear gradient @ angle, need set start , end points appropriately. example, if used (0,0) , (1,1) start , end points, gradient run top left bottom right, @ 45 degree angle.
working out specific start , end points needs therefore matter of trigonometry.
Comments
Post a Comment