views:

15

answers:

0

Partly as a programming exercise, and partly because we may need to include such images in an app some day, I've been trying to figure out how to draw an image like the selected tab in a UITabBar.

The basic operation is simple enough in concept: the icon's alpha is used as a mask to draw the blue gradient image onto the tab. (Though I can't for the life of me figure out how one actually uses an image's alpha as a mask in Core Graphics. I ended up drawing the gradient first, then using a transparency layer with kCGBlendModeDestinationIn to draw the icon.)

example of selected tab image

But look closely at the real thing, and you'll see that there's also a bright outline just inside the opaque regions of the icon. How would one achieve that effect? I'm guessing that this is another drawing pass, maybe blending in lightening mode, but is there a straightforward way to get just the edge pixels of the icon?