Gradient Füllen Sie Swift für iOS-Charts aus

Ich versuche, eine schöne Verlaufsfüllung zu erstellen, wie in den Demos auf der Seite mit den iOS-Diagrammen dargestellt. Ich kann dies jedoch nicht in swift vs obj-c herausfinden. Hier ist der obj-c Code:

NSArray *gradientColors = @[
                    (id)[ChartColorTemplates colorFromString:@"#00ff0000"].CGColor,
                    (id)[ChartColorTemplates colorFromString:@"#ffff0000"].CGColor
                    ];
CGGradientRef gradient = CGGradientCreateWithColors(nil, (CFArrayRef)gradientColors, nil);

set1.fillAlpha = 1.f;
set1.fill = [ChartFill fillWithLinearGradient:gradient angle:90.f];

Nun ist hier meine Version davon in Kürze:

    let gradColors = [UIColor.cyanColor().CGColor, UIColor.init(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)]
    let colorLocations:[CGFloat] = [0.0, 1.0]
    let gradient = CGGradientCreateWithColors(CGColorSpaceCreateDeviceRGB(), gradColors, colorLocations)

Was mir fehlt, ist das: Chart Fill fillWithLinearGradient

Ich kann den fillWithLinearGradient nirgends im Pod finden, daher bin ich etwas verwirrt.

Vielen Dank im Voraus für jede Hilfe! Raube

Antworten auf die Frage(8)

Ihre Antwort auf die Frage