我是Core Graphics的新手,我试着画圆圈.它们可以是透明的(仅中风)并填充笔触颜色.所以方法看起来像这样: 
  
  
 
+ (UIImage *)iconImageWithColor: (UIColor *)markColor strokeOnly:(BOOL)strokeOnly
{
    CGRect rect = CGRectMake(0.0f,0.0f,20.0f,20.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGPathRef clippingPath = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:7.5f].CGPath;
    CGContextAddpath(context,clippingPath);
    CGContextClip(context);
    CGContextSetFillColorWithColor(context,strokeOnly == YES ? [[UIColor clearColor] CGColor] : [markColor CGColor]);
    CGContextFillRect(context,rect);
    CGPathRef path = CGPathCreateWithRoundedRect(rect,10.f,NULL);
    [markColor setstroke];
    CGContextAddpath(context,path);
    CGContextDrawPath(context,kCGPathFillstroke);
    UIImage *image = UIGraphicsGetimageFromCurrentimageContext();
    UIGraphicsEndImageContext();
    return image;
} 
 结果很奇怪 – 看起来图像的分辨率非常低.是否有可能使结果图像在视网膜显示器上看起来很好?
解决方法
 UIGraphicsBeginImageContext创建一个比例为1的上下文,因此非视网膜. 
 
你想要用的是
        你想要用的是
UIGraphicsBeginImageContextWithOptions(rect.size,NO,0.0f)
scale 0表示它将使用设备屏幕比例