ios - 如何在CGrect中制作尖锐的形状边界?

标签 ios objective-c cgrect

我正在使用CGrect绘制带有边框的圆,但是我没有得到圆的尖锐边框,这是我的代码:

 CGRect rect = CGRectMake(lastPoint1.x - CircleRadius ,lastPoint1.y - CircleRadius,CircleDia,CircleDia);
    CGContextSetFillColorWithColor(ctx, [Util_color getThemeColor].CGColor);
    CGContextFillEllipseInRect(ctx, rect);
    CGContextSetRGBStrokeColor(ctx, 255.0, 255.0, 255.0, 1.0);
    CGContextStrokeEllipseInRect(ctx, rect);
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
    CGContextSetLineWidth(ctx, 3.0);
     CGContextSetShouldAntialias(ctx, YES);
    CGContextSetLineCap(cox,kCGLineCapRound);

但是我仍然会得到模糊的边框!有什么方法可以使用CGrect获得清晰的边框吗?

最佳答案

您在像素之间绘制。请参阅此处以获取说明和修正:http://orangejuiceliberationfront.com/are-your-rectangles-blurry-pale-and-have-rounded-corners/

(这是How to get a 1 pixel line with NSBezierPath?的副本,我最初为此写了说明)

关于ios - 如何在CGrect中制作尖锐的形状边界?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41980963/

相关文章:

ios - SwiftUI : Picker does not update correctly when changing datasource

ios - 停止从右到左语言的 UIImage 翻转

ios - MFMailComposeViewController 栏背景颜色在 iOS7 中未更改

ios - 在 CGRect iOS 中添加边框

ios - CocoaPods:构建成功但颜色为红色

ios - 如何获取从 nib ios 加载的自定义 View 的实际大小

ios - 我们如何在 ios 中使用 for 循环为 1 个或多个文本字段设置背景颜色

ios - 如何使 UICollectionView 宽度依赖于屏幕尺寸?

swift - 将 CGPoint 数字拆分为两个 CGFloat

ios - 为什么 CGRectInfinite 和所有成员都设置为 INFINITY 的 CGRect 之间存在差异?