这是一个简单的绘图
- (void)drawRect:(CGRect)rect
{
//vertical line with 1 px stroking
UIBezierPath *vertLine = [[UIBezierPath alloc] init];
[vertLine moveToPoint:CGPointMake(20.0, 10.0)];
[vertLine addLineToPoint:CGPointMake(20.0, 400.0)];
vertLine.lineWidth = 1.0;
[[UIColor blackColor] setStroke];
[vertLine stroke];
//vertical rectangle 1px width
UIBezierPath *vertRect= [UIBezierPath bezierPathWithRect:CGRectMake(40.0, 10.0, 1.0, 390.0)];
[[UIColor blackColor] setFill];
[vertRect fill];
}
在非视网膜 3GS 和模拟器上,第一行模糊,看起来比 1 px 宽,但第二行清晰。
不幸的是,我既没有 iPhone4 也没有新的 iPad 来测试,但在视网膜模拟器上,两条线看起来都一样。
问题:对于非视网膜和视网膜设备,矩形而不是描边是获得相同结果的唯一方法吗?