iphone CGContextSetLineWidth 画线的问题

转自:http://blog.csdn.net/jxncwzb/article/details/6267154

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor (context, 142.0/ 255.0, 161.0/ 255.0, 189.0/ 255.0, 1.0);
CGContextSetLineWidth(context, 1.0 );//这里设置成了1但画出的线还是2px,给我们的感觉好像最小只能是2px。
CGContextMoveToPoint(context, 1.0 , 24.0 );
CGContextAddLineToPoint(context, 83.0 , 24.0 );
CGContextClosePath(context);
CGContextStrokePath(context);
 
原因是因为默认情况下,锯齿显示,所以它显示为宽度= 2.0,关闭消除锯齿可以解决问题了。
 
CGContextSetShouldAntialias(context, NO );
原文地址:https://www.cnblogs.com/wangpei/p/3776741.html