I want to draw my own tabs for NSTabViewItem
s. My Tabs should look different and start in the top left corner and not centered.
How can I do this?
It's very easy to use a separate NSSegmentedCell
to control tab selection in an NSTabView
. All you need is an instance variable that they can both bind to, either in the File's Owner, or any other controller class that appears in your nib file. Just put something like this in the class Interface declaraton:
@property NSInteger selectedTabIndex;
Then, in the IB Bindings Inspector, bind the Selected Index of both the NSTabView
and the NSSegmentedCell
to the same selectedTabIndex
property.
That's all you need to do! You don't need to initialize the property unless you want the default selected tab index to be something other than zero. You can either keep the tabs, or make the NSTabView
tabless, it will work either way. The controls will stay in sync regardless of which control changes the selection.