我正在尝试创建一个圆形加载条,并想使用Core Graphics而不是遮罩图像来创建效果。但是,我没有得到我所希望的保真度:
无论我尝试了什么,锯齿似乎都很严重。抗锯齿已经开启,并且我已经尝试将“flatness”降低到
绘画代码在CALayer的子类中:
![enter image description here](https://istack.dev59.com/hXg23.webp)
CGContextRef
的0.1。该图像来自(Retina)模拟器,在设备上看起来稍微好一些,但仍然不是很好。绘画代码在CALayer的子类中:
-(void)drawInContext:(CGContextRef)ctx {
CGPoint center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
CGFloat delta = toRadians(360 * percent);
CGFloat innerRadius = 69.5;
CGFloat outerRadius = innerRadius + 12;
CGContextSetFillColorWithColor(ctx, [UIColor colorWithRed:99/256.0 green:183/256.0 blue:70/256.0 alpha:.5].CGColor);
CGContextSetStrokeColorWithColor(ctx, [UIColor colorWithRed:99/256.0 green:183/256.0 blue:70/256.0 alpha:10.0].CGColor);
CGContextSetLineWidth(ctx, 1);
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRelativeArc(path, NULL, center.x, center.y, innerRadius, -(M_PI / 2), delta);
CGPathAddRelativeArc(path, NULL, center.x, center.y, outerRadius, delta - (M_PI / 2), -delta);
CGPathAddLineToPoint(path, NULL, center.x, center.y-innerRadius);
CGContextAddPath(ctx, path);
CGContextFillPath(ctx);
CGContextAddPath(ctx, path);
CGContextStrokePath(ctx);
}
这是Core Graphics所能做到的最好吗,还是我漏掉了什么?
ctx
还是框架将其传递给您?NSLog(“%@”,[[[UIApplication sharedApplication] keyWindow] recursiveDescription])
的输出是什么? - rob mayoff