如何在 Interface Builder 中创建 1px 线? [英] How do I create a 1px line in Interface Builder?

查看:24
本文介绍了如何在 Interface Builder 中创建 1px 线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意,我希望制作一条 1px 的线,而不是 1pt 的线.这意味着无论屏幕比例如何,它都应该是 1px(因此在 Retina 设备上为 0.5pt).

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).

我可以通过编程方式执行此操作,但我可以在 Interface Builder 中执行此操作吗?例如,我不能将 UIView 的高度设置为小于 1.

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.

如果我可以在 IB 中做到这一点,那么我不必声明一个插座并在 awakeFromNib 中手动设置框架.

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

推荐答案

通过 Interface Builder 添加一个 0.5 像素高度约束:

Add a 0.5 pixel height constraint via Interface Builder:

这篇关于如何在 Interface Builder 中创建 1px 线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆