Нарисуй простой круг
Я пытаюсь сделать 20x20 UIImage с простым синим кругом. Я пытаюсь с этой функцией, но в результате синий круг в черном квадрате. Как мне удалить черный квадрат вокруг круга?
Функция:
+ (UIImage *)blueCircle {
static UIImage *blueCircle = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(20.f, 20.f), YES, 0.0f);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
CGRect rect = CGRectMake(0, 0, 20, 20);
CGContextSetFillColorWithColor(ctx, [UIColor cyanColor].CGColor);
CGContextFillEllipseInRect(ctx, rect);
CGContextRestoreGState(ctx);
blueCircle = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
});
return blueCircle;
}
фактический результат: