How can I draw a slight white 'glow' around a button or label in 10.5 and later? I have seen some apps do it, but I am still confused how I should do this.
-
2can you point us to an screenshot, to know what you are referring to? – Victor Jalencas Mar 23 '10 at 06:14
-
I can't get a screen shoot, but what I mean is something like Photoshop's outer glow on a button in white, that originates below the actual button, and then slowly fades out. – Tristan Mar 23 '10 at 13:44
1 Answers
See NSShadow. You'd create and set a shadow (saving your graphics context beforehand), then draw the basic shape of your button, unset it (by restoring your graphics context), then continue drawing as usual.
In the case of a ready-made control like NSButton, you will need to subclass and override its cell drawing (and possibly make the host NSButton control itself a bit larger to accommodate the larger area needed to encompass the "glow" of the cell).
You might be able to avoid this with a label by setting its font shadow, but I don't think IB lets you do this, so you'd programmatically give the label an attributed string (via its -setAttributedString: method). The attributes would include the NSShadow (configured as desired) as the NSShadowAttributeName.

- 60,946
- 14
- 140
- 135