Transparenten hintergrund UIView drawRect Kreis

Ich bin zeichnen Sie einen Kreis mit einer weißen Kontur und eine Farbe angegeben, indem eine Eigenschaft mit diesem code:

- (void)drawRect:(CGRect)rect {

    CGContextRef contextRef = UIGraphicsGetCurrentContext();

    CGContextClearRect(contextRef, rect);

    //Set the border width
    CGContextSetLineWidth(contextRef, 1.5);

    //Set the circle fill color to GREEN
    CGFloat red, green, blue, alpha;
    BOOL didConvert = [_routeColor getRed:&red green:&green blue:&blue alpha:&alpha];

    CGContextSetRGBFillColor(contextRef, red, green, blue, 1.0);

    //Set the cicle border color to BLUE
    CGContextSetRGBStrokeColor(contextRef, 255.0, 255.0, 255.0, 1.0);

    //Fill the circle with the fill color
    CGContextFillEllipseInRect(contextRef, rect);

    //Draw the circle border
    CGContextStrokeEllipseInRect(contextRef, rect);
}

Dem Bild, das ich wieder wie folgt aussieht:

Transparenten hintergrund UIView drawRect Kreis

Wie kann ich entfernen Sie die schwarzen?

  • Vorschlag - loszuwerden, die Anrufe zu CGContextSetRGBFillColor und CGContextSetRGBStrokeColor. Führen Sie stattdessen folgende Schritte: [_routeColor setFill]; [[UIColor whiteColor] setStroke];. Und FYI - Farbe-Werte müssen im Bereich 0.0 - 1.0, so dass all Ihre 255.0-Werte 1.0.
InformationsquelleAutor user3741418 | 2014-07-02
Schreibe einen Kommentar