CoreGraphics 圆角厚度
每当我在 iPhone 上描画带有圆角的路径时,圆角都会比描画路径的其余部分更粗。请参阅此处了解我的意思:
圆角厚度 http://img181.imageshack.us/ img181/6372/screenshot20100320at123.png
不知道为什么会发生这种情况,有什么想法吗?
Whenever I stroke a path with rounded corners on iPhone, the rounded corners are thicker than the rest of the stroked path. See here for what I mean:
rounded corner thickness http://img181.imageshack.us/img181/6372/screenshot20100320at123.png
Not sure why this happens, any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我同意 Peter Hosey 的分析,即线条的外半部分被剪掉,但我的建议是将所有坐标向内移动 0.5 像素。这样,您的直线也会更加清晰(不会在 2 个屏幕像素上进行抗锯齿处理)。
I agree with Peter Hosey's analysis that the outer half of your lines is getting clipped off, but my recommendation would be to move all the coordinates .5 pixels inward instead. This way your straight lines will be crisper (not antialiased across 2 screen pixels) as well.
我怀疑你是在矩形剪切路径内绘制的;角完全落在矩形内,但边被切成两半:一半在剪切路径内,因此被绘制,一半在外部,因此被剪切掉。
在抚摸它之前尝试将路径添加到剪切路径。
为此,您需要将 CGPath 添加到上下文的当前路径两次:
I suspect that you're drawing within a rectangular clipping path; the corners fall completely within the rectangle, but the sides get cut in half: half inside the clipping path and so drawn, half outside and so clipped out.
Try adding the path to the clipping path before stroking it.
To do this, you will need to add the CGPath to the context's current path twice:
只是看起来比较厚而已。如果放大它,您会发现看起来像几个额外的黑色像素实际上是由抗锯齿引起的一些灰色像素。
尝试关闭抗锯齿功能,看看结果是否看起来更好。
编辑:右下角似乎也有阴影效果。
It just looks thicker. If you zoom in on it you will see what looks like a couple extra pixels of black is actually some pixels of gray caused by antialiasing.
Try turning off antialiasing to see if the result looks better.
Edit: Also the bottom right corner seems to have a drop shadow effect.