Search code examples
iosuikitinterface-builderretina-display

How do I create a 1px line in Interface Builder?


Note, I'm looking to make a 1px line, not a 1pt line. Meaning it should be 1px regardless of screen scale (so 0.5pt on Retina devices).

I can do this programmatically, but can I do it in the Interface Builder? For example I cannot set a UIView to have a height of less than 1.

If I can do it in IB then I don't have to declare an outlet and manually set the frame in awakeFromNib.


Solution

  • Add a 0.5 pixel height constraint via Interface Builder:

    Xcode 7.3 right down corner: add Height constraint in Pin.