r d*_*rte 4 core-graphics objective-c uiview ios retina-display
我有一个UIView,它从drawRect:rect中画一个圆圈.在Retina显示屏上阅读Apple dev信息后,似乎使用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];
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助,Rob
r d*_*rte 10
哎呀,首先需要抗锯齿:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(context, YES);
Run Code Online (Sandbox Code Playgroud)
我在绘图之前添加了这个,然后将其设置为NO,然后立即绘制另一个圆圈.这两个圆圈并排表明这就是问题所在.