How do I create a 1px line in Interface Builder?(如何在 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 线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Interface Builder 中创建 1px 线?
基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
