使用 Core Graphics 绘图在 Retina 显示屏上看起来很厚重
我有一个 UIView,它从 drawRect:rect 内部绘制一个圆。在阅读了有关 Retina 显示屏的 Apple 开发信息后,似乎使用 Core Graphics 意味着绘图将自动利用更高的分辨率。然而,与徽章图标中的类似圆圈相比,这个简单的圆圈看起来相当粗。显然,我将它与具有光泽和阴影的东西进行比较,但我认为很明显我的也没有被绘制。我尝试截取苹果图标徽章和我的圆圈的屏幕截图,它们在我的 Mac 上看起来几乎相同 - 不过,当在手机上查看时,差异很明显。我在这里缺少一些简单的东西吗?
这是我在drawRect:rect中使用的绘图代码
UIBezierPath* aPath = [UIBezierPath bezierPathWithOvalInRect:
CGRectMake(0, 0, 22, 22)];
[[UIColor whiteColor] setStroke];
[[UIColor redColor] setFill];
CGContextRef aRef = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(aRef, 10, 10);
aPath.lineWidth = 3;
[aPath fill];
[aPath stroke];
感谢您的帮助, 抢
I have a UIView that draws a circle from inside drawRect:rect. After reading the Apple dev info on the Retina display, it seemed like using Core Graphics meant that the drawings would automatically take advantage of the higher res. This simple circle, however, looks pretty chunky as compared to a similar circle in a badge icon. Obviously I'm comparing it to something that has gloss and shadow but I think it's pretty obvious that mine is not being drawn as well. I tried taking screenshots of apple's icon badge and my circle and they look about the same on my mac - the difference is obvious when looking at each on the phone, though. Is there something simple I'm missing here?
This is the drawing code that I'm using in drawRect:rect
UIBezierPath* aPath = [UIBezierPath bezierPathWithOvalInRect:
CGRectMake(0, 0, 22, 22)];
[[UIColor whiteColor] setStroke];
[[UIColor redColor] setFill];
CGContextRef aRef = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(aRef, 10, 10);
aPath.lineWidth = 3;
[aPath fill];
[aPath stroke];
Thanks for any help,
Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哎呀,它首先需要抗锯齿:
我在绘制之前添加了它,然后将其设置为“否”,然后立即绘制了另一个圆圈。并排的两个圆圈表明这就是问题所在。
Oops, it needed antialiasing first:
I added this before drawing, then set it to NO and drew another circle immediately afterward. The two circles, side by side, show that this was the problem.