如何创建0.5像素的线宽 [英] How to create a line width of 0.5 pixels
问题描述
在iOS 7中,表格视图的分隔线比以前的ios更薄,看起来宽度为0.5像素。
in iOS 7 the table view's separator line is thinner than previous ios, and it looks like its 0.5 px width.
我需要使用类似的分隔线(仅垂直)将单元格拆分为2,我希望此行与常规分隔线的宽度相同。
I need to split a cell in 2 with a similar separator line (only vertically) and I want this line to be the same width as the regular separator line.
所以我想知道添加这样一条线的最佳方法是什么?
So I'm wondering what is the best way to add such a line?
如果我使用 UIView
并将其宽度设置为0.5它将不可见,如果我设置它的宽度为1.0当然我的线宽为1.0px而不是0.5px。
If I use a UIView
and set its width to 0.5 It won't be visible, and if I set its width to 1.0 than of course I will get a line width of 1.0px not 0.5px.
我尝试使用视网膜大小为1.0px的资源,但效果并不好......
I tried to use a resource with a retina size of 1.0px but it didn't worked as well...
推荐答案
我执行了以下步骤:
- 创建高度为1px的约束
- 使用IBOutlet(文件.m)连接约束
- 在ViewDidLoad
中更改约束的常量0.5
- Create a constraint with 1px height
- Connect the constraint with IBOutlet (file .m)
- Change the constant of the constraint for 0.5 in the ViewDidLoad
它对我有用。
这篇关于如何创建0.5像素的线宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!