我的drawInContext方法看起来像这样:
- (void)drawInContext:(CGContextRef)context {
CGRect circleRect = CGRectInset(self.bounds, 1, 1);
UIColor * __autoreleasing borderColor = [UIColor whiteColor];
UIColor * __autoreleasing backgroundColor = [UIColor colorWithWhite:0 alpha: 0.75];
CGContextSetFillColorWithColor(context, backgroundColor.CGColor );
CGContextSetStrokeColorWithColor(context, borderColor.CGColor );
CGContextSetLineWidth(context, 2.0f);
CGContextFillEllipseInRect(context, circleRect);
CGContextStrokeEllipseInRect(context, circleRect);
CGFloat radius = MIN(CGRectGetMidX(circleRect), CGRectGetMidY(circleRect));
CGPoint center = CGPointMake(radius, CGRectGetMidY(circleRect));
CGFloat startAngle = -M_PI / 2;
CGFloat endAngle = self.progress * 2 * M_PI + startAngle;
CGContextSetFillColorWithColor(context, borderColor.CGColor );
CGContextMoveToPoint(context, center.x, center.y);
CGContextAddArc(context, center.x, center.y, radius, startAngle, endAngle, 0);
CGContextClosePath(context);
CGContextFillPath(context);
[super drawInContext:context];
}
Run Code Online (Sandbox Code Playgroud)
但是在我的iPhone Retina显示屏上,截图显示它看起来非常像pix.猫怎么修这个?

too*_*oom 11
好的,我找到了解决方案.要绘制精美缩放的图像,需要执行以下操作:
pie_layer.contentsScale = [UIScreen mainScreen].scale;
Run Code Online (Sandbox Code Playgroud)
另请参阅此文章:CGContext文本绘图无法在iPhone 4上扩展
| 归档时间: |
|
| 查看次数: |
1262 次 |
| 最近记录: |