CGContext /NSBezierPath stroke line width thicker
2014-09-24 10:32
253 查看
down votefavorite | rounded corners are clearly thicker than the rest of the path. 当我们用整数定义某路径时,路径的坐标总是在两个像素之间的,而NSBezierPath在绘制线条时,线条宽度刚好平均分配在路径两侧,而当宽度为1或其它奇数时,两侧就会出现半像素的情况,并且在非Retina显示下,每一个需要绘制的像素是与屏幕最终显示的单元是一一对应的,如图: ![]() CGContextRef context = UIGraphicsGetCurrentContext(); CGContextBeginPath(context); // NSInsetRect (rect, lineWidth/2, lineWidth/2)
rect, 1.0, 1.0);[/code] CGContextMoveToPoint(context, rect.origin.x + kRoundedRectButtonRadius, rect.origin.y); CGContextAddArc(context, rect.origin.x + rect.size.width - kRoundedRectButtonRadius, rect.origin.y + kRoundedRectButtonRadius, kRoundedRectButtonRadius, 3 * M_PI_2, 0, NO); CGContextAddArc(context, rect.origin.x + rect.size.width - kRoundedRectButtonRadius, rect.origin.y + rect.size.height - kRoundedRectButtonRadius, kRoundedRectButtonRadius, 0, M_PI_2, NO); CGContextAddArc(context, rect.origin.x + kRoundedRectButtonRadius, rect.origin.y + rect.size.height - kRoundedRectButtonRadius, kRoundedRectButtonRadius, M_PI_2, M_PI, NO); CGContextAddArc(context, rect.origin.x + kRoundedRectButtonRadius, rect.origin.y + kRoundedRectButtonRadius, kRoundedRectButtonRadius, M_PI, 3 * M_PI_2, NO); CGContextClosePath(context); CGContextSetLineWidth(context, 1.7); CGContextStrokePath(context); |
相关文章推荐
- 苹果iso开发:[10]CGContextSetLineWidth
- iOS_CGContextSetLineWidth
- IOS CGContextSetLineWidth无法设置1像素线宽?
- 原 IOS CGContextSetLineWidth无法设置1像素线宽?
- iOS CGContextSetLineWidth无法设置1像素线宽?
- IOS CGContextSetLineWidth无法设置1像素线宽?
- iphone CGContextSetLineWidth 画线的问题
- iphone CGContextSetLineWidth 画线的问题
- 苹果iso开发:[10]CGContextSetLineWidth
- iOS绘图系列二:画直线 CGContextMoveToPoint,CGContextAddLineToPoint,CGContextAddLines,
- iOS - CGContextAddLineToPoint 绘图崩溃:
- iOS绘图系列二:画直线 CGContextMoveToPoint,CGContextAddLineToPoint,CGContextAddLines,
- CGContextAddLines和CGContextAddLineToPoint在线条半透明时候的区别
- CGContextAddLines和CGContextAddLineToPoint在线条半透明时候的区别
- iOS: CGContext的函数CGContextAddLineToPoint
- 使用UIBezierPath绘图控制台<Eorro>CGContextSaveGState: invalid context 0x0,CGContextSetLineWidth: invalid co
- 【坑】html5中使用context.lineWidth设置线的宽度是1,然而输出的宽度是2的原因
- 升级到XCode7后出现 <Error>: CGContextSaveGState: invalid context 0x0.
- 一种解决办法:CGContextSaveGState: invalid context 0x0
- CGContext用法详解