
Can I know how to have the emboss effect as the text “Reminders” as shown on the picture?
It looks like the text are embedded?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
UPDATE FOR iOS 7.0
In iOS 7.0, Apple added a new attribute,
NSTextEffectAttributeName, for attributed strings. If your deployment target is iOS 7.0 or later, you can set this attribute toNSTextEffectLetterpressStyleto draw an attributed string in an embossed style.ORIGINAL
I can’t say for certain how Apple draws the embossed text. It looks to me like they fill the string glyphs with a reddish color, then apply a shadow around the interior edges of the glyphs, and also apply a very faint shadow along the top outside edges of the glyphs. I tried it out and here’s what it looks like:
On top is my rendering. Below that is a simple UILabel with shadow as Chris suggested in his answer. I put a screen shot of the Reminders app in the background.
Here’s my code.
First, you need a function that creates an image mask of your string. You’ll use the mask to draw the string itself, and then to draw a shadow that only appears around the inside edges of the string. This image just has an alpha channel and no RGB channels.
Second, you need a function that inverts that mask. You’ll use this to make CoreGraphics draw a shadow around the inside edges of the string. This needs to be a full RGBA image. (iOS doesn’t seem to support grayscale+alpha images.)
You can use those in a function that draws the string in red and applies a shadow to its interior edges.
Next you need a function that takes an image and returns a copy with a faint upward shadow.
Finally, you can combine those functions to create an embossed image of your string. I put my final image into a
UIImageViewfor easy testing.