1

My app has an NSToolbar with a horizontal NSSplitView below it. An NSSegmentedControl in the toolbar moves with the splitview's divider, just like the one in OS X's Finder. NSLayoutGuide was used to align the two "views" from different storyboard "scenes". I shared this approach in this related question.

However, I don't know how to move the label with the icon. I've set the minSize and maxSize, but the label is fixed. In the first screenshot below, the "View Mode" label is not right below the segmented control.

It will be easy to add constrains to the label if I can access it. But I haven't found the API in NSToolbarItem, which only has a public view property. I've examine the view's hierarchy (the second screenshot), but I don't think I should use the variables with the _ prefix.

A related but different question is here. That question doesn't take moving into account.

the problem: label is not below the icons

view hierarchy

Community
  • 1
  • 1
LShi
  • 1,500
  • 16
  • 29

1 Answers1

0

You could try subclassing the NSToolbar setting the title to @"" and then creating your own UILabel and adding it as a subview? then you could reference it's property name and move it wherever you like

RyanOfCourse
  • 832
  • 1
  • 8
  • 15
  • Thanks! But I don't think this is good since it will break the factory toolbar behaviours, i.e. show/hide labels and size changing. – LShi Sep 14 '15 at 16:02