gpt4 book ai didi

objective-c - 使用 Core Graphics 绘图在 Retina 显示屏上看起来很笨重

转载 作者:可可西里 更新时间:2023-11-01 05:07:07 27 4
gpt4 key购买 nike

我有一个 UIView,它从 drawRect:rect 内部绘制一个圆。在阅读 Retina 显示屏上的 Apple 开发信息后,使用 Core Graphics 似乎意味着绘图将自动利用更高分辨率。然而,与角标(Badge)图标中的类似圆圈相比,这个简单的圆圈看起来很粗。显然我将它与具有光泽和阴影的东西进行比较,但我认为很明显我的也没有被绘制。我尝试截取苹果图标角标(Badge)和我的圆圈的屏幕截图,它们在我的 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];

感谢您的帮助,罗布

最佳答案

糟糕,它首先需要抗锯齿:

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(context, YES);

我在画图之前加上了这个,然后设置为NO,紧接着又画了一个圆圈。并排的两个圆圈表明这就是问题所在。

关于objective-c - 使用 Core Graphics 绘图在 Retina 显示屏上看起来很笨重,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5291510/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com