Setting Horizontal Line (NSBox) line width in Interface Builder

2.9k views Asked by At

I have an application that I am building am making use of Horizontal Line (which is just a special case of NSBox). I've placed the component into the interface, but what to adjust the thickness of the line.

NSBox has a setBorderWidth method, but doesn't seem to have this exposed when in Interface Builder. I would prefer not to do this manually, as I don't want to have to maintain an object simply to adjust this single value.

Is there a way to set this via Interface Builder that I am just missing?

Or, failing that, is there a better way to put a Horizontal Line in your UI such that you can control it's attributes via Interface Builder?

2

There are 2 answers

0
Asteroids With Wings On

The best way is to instead add a Custom Box control (which is an NSBox), set its box type to Custom and its border type to Line.

Then set the control's height to 1 in the normal way, as well as its tint and whatever else you need.

The Horizontal Line control is really just a shortcut to get a NSBox that's been hard-coded to use the default separator line style; it doesn't allow you to configure much else. But, despite the name, it's neither the only nor arguably the best way to make a horizontal line.

2
Joshua Nozzi On

On the Attributes pane of the inspector, set the Border Type to Custom. Then on the Size pane, set the border width as needed.