I have a 开发者_开发问答class that draws a rounded rectangle, puts a border around it, and a piece of text in the middle.
I would like to add a shadow/outline to the text, so that the text looks inset like the title on a UINavigationBar.
Is this possible with CoreGraphics?
Inset text is created by adding a white shadow without a blur below the text (assuming light coming from the top.)
In CoreGraphics, set the shadow before drawing text
CGContextSetShadowWithColor(ctx,
CGSizeMake(0, -1),
0,
[UIColor whiteColor].CGColor);
@Andrew you can set the shadow offset property of the button title label by calling setTitleShadowOffset
: method on the button.
Edit:
I hope these links might help
http://www.raywenderlich.com/2079/core-graphics-101-shadows-and-gloss http://www.wideasleep.com/blog/?p=199
精彩评论