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

后端 未结 10 1773
独厮守ぢ
独厮守ぢ 2020-12-04 10:30

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 programmatica

10条回答
  •  再見小時候
    2020-12-04 11:23

    EDIT: This answer was for @2x only devices. At that time @3x was not yet on the market!

    Nowadays, @mdvs's answer seems to be the cleanest.


    Making 1px line in IB is hard even for retina-only devices. Finally I've achieved it using the User Defined Runtime Attributes.

    Here's a screenshot for setting the Height Constraint to 0.5 px (which is 1px on retina devices).

提交回复
热议问题