Re: Trying to create a 1px width NSBox
Re: Trying to create a 1px width NSBox
- Subject: Re: Trying to create a 1px width NSBox
- From: Quincey Morris <email@hidden>
- Date: Sun, 08 Mar 2015 19:51:07 +0000
On Mar 8, 2015, at 12:02 , Patrick J. Collins <email@hidden> wrote:
>
> Except it seems to have a default unchangable width of 5px... ???
In IB, if you set the metrics inspector tab to “Alignment” rather than “Frame”, it shows as 1, not 5. The actual frame of the NSBox view isn’t important, if the view draws the line thickness you want and is transparent elsewhere.
> How can I get a simple 1px solid colored object that I can use for
> this purpose?
You don’t want 1 px, you want 1 pt. Thinking in pixels is going to get you messed up when it comes to retina displays.
A different approach is to use an image view, and design your own vertical line as an image. If you design the image properly, when you bring the image into your Xcode .xcassets file, you can get it sliced so that it’s stretchable vertically. (This is 10.10 only. In earlier versions of OS X you have to use the 3- or 9-part image drawing API to get the same result, which means you’d need a custom view.)
That way you can have a line that will adapt to any height, and can have a nice gradient treatment (for example) at the top and bottom. You could also make it wider than 1pt and partially transparent, except perhaps for a 1pt center line, so that it’s easier to see than a simple 1pt-wide shape, but it won't obscure much of what’s under it.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden