How do I comfortably use CGColor in an NSArray with CGGradient

后端 未结 1 1713
抹茶落季
抹茶落季 2021-02-08 03:40

I have two UIColor instances and want to use them creating a gradient. The code works, but it gives me a warning when I call the arrayWithObject: constructor:

1条回答
  •  醉梦人生
    2021-02-08 03:56

    Try this

    UIColor *startColor, *endColor; 
       // ...
       NSArray *colors = [NSArray arrayWithObjects:
                          (id)startColor.CGColor, (id)endColor.CGColor, nil];
       CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, 
                         (CFArrayRef) colors, NULL);
    

    0 讨论(0)
提交回复
热议问题