I have a class that takes an NSString
as a parameter, uses Core Text to get the siz开发者_C百科e of the text, extract each line and renders the text line with different x offsets to give a skewed effect.
I also apply a shadow when Core Graphics is drawing the lines of text, however this shadow get's clipped by the views frame
and clipToBounds
does not resolve this.
Question 1.
I understand that clipsToBounds = NO
will only affect subviews. Does this mean UIViews
, or does it apply to sub CALayer
s too?
Question 2.
When I draw the CTLines
can I use a different UIView
or CALayer
s context to render, so I can use clipsToBounds
properly?
clipsToBounds only applies to sublayers, not layer contents, yes.
You can expand the size of your target layer to encompass the area you need for your shadow, which you can figure out from the shadow’s radius and offset. You can manipulate the
bounds
property of the layer so that the origin stays at the same place even when the layer has been grown.
For instance, if you start with a (100,100) rectangle and have a 1px shadow with (0,0) offset:
layer.bounds = CGRectMake(-1, -1, 102, 102).
精彩评论