我正在尝试创建一个高度为1像素的
UIView
。 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,20,1)];
在非Retina的iPhone上,这个问题还好,但在Retina上看起来像是2个像素高。
出了什么问题?
UIView
。 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,20,1)];
在非Retina的iPhone上,这个问题还好,但在Retina上看起来像是2个像素高。
出了什么问题?
在Retina屏幕上,实际像素和UIKit像素是不同的。
尝试这样做:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,20,1/[[UIScreen mainScreen] scale])];
这是因为CGRectMake使用的是点而不是像素。 在Retina设备上,它们将dpi加倍,因此对于1个点,现在有2个像素。 在非Retina设备上,1个点=1个像素。