Zeichne einen einfachen Kreis uiimage

Ich versuche, ein 20x20 UIImage mit einem einfachen blauen Kreis.
Ich versuche mit dieser Funktion, aber das Ergebnis ist ein blauer Kreis auf einem schwarzen Quadrat.
Wie Entferne ich das schwarze Quadrat um den Kreis herum?

Funktion:

+ (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;
}

tatsächliche Ergebnis:
Zeichne einen einfachen Kreis uiimage

InformationsquelleAutor der Frage Mattia Lancieri | 2013-11-21

Schreibe einen Kommentar