I'm trying to recreate the segmented control used in Xcode where the images are drawn with a blue tint.
For example in Interface Builder:
So far I have a custom NSSegmentedCell
overriding - (void)drawSegment:(NSInteger)segment inFrame:(NSRect)frame withView:(NSView *)controlView
, but I'm stuck at how to draw the segment image (1) with the gray tint and (2) with the blue tint if it is selected.
Also, it looks like the images are drawn with a bezel or gradient effect. When I draw the segment image myself it is simply black (because I use template images).
How can I recreate the segment from above?
Use an NSSegmentedControl
object with style NSSegmentStyleTexturedRounded
and mode NSSegmentSwitchTrackingSelectAny
.
The way in which this is achieved for single buttons differs slightly from that of segmented controls:
IconTemplate
or Template
appended to its (original) nameNSTexturedRoundedBezelStyle
Button Style↳ For example I have three .png
images in my resources, MiddlePanelIconTemplate.png, CardPanelIconTemplate.png, and ReturnPanelIconTemplate.png using Round Textured Button Cell Style.
⌘ OS X Human Interface Guidelines | Window-Frame Controls
Answer provided by 'L'l worked ok for me, but appending IconTemplate to your image name it's not working on Xcode 7.3 anymore. Instead of that, you have to go to your Assets catalog, choose the image you want to use and on the right panel you have to select the Attributes Inspector and on the combo that says 'Render As' select 'Template Image'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With