Gradient Fill in Swift for iOS-Charts

后端 未结 5 1888
醉梦人生
醉梦人生 2020-12-15 10:28

I am trying to create a nice gradient fill as seen in the demos on the ios-charts page. However, I cannot figure this out in swift vs obj-c. Here is the obj-c code:

5条回答
  •  难免孤独
    2020-12-15 10:45

    I believe this is the code that you are looking for. You should be able to use the same ChartFill class in Swift to set set1.fill.

    let gradColors = [UIColor.cyanColor().CGColor, UIColor.clearColor.CGColor]
    let colorLocations:[CGFloat] = [0.0, 1.0]
    if let gradient = CGGradientCreateWithColors(CGColorSpaceCreateDeviceRGB(), gradColors, colorLocations) {
        set1.fill = ChartFill(linearGradient: gradient, angle: 90.0)
    }
    

提交回复
热议问题