Sort Colors (Objective-C)

后端 未结 2 962
离开以前
离开以前 2021-02-14 14:54

I\'m doing this sort of thing:

- (NSArray*)colors {
    float divisor = .3333;
    NSMutableArray *retVal = [NSMutableArray array];
    for (float one=0; one <         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-14 15:02

    I think using [UIColor colorWithHue:saturation: brightness: alpha:] is your best bet. If you fix saturation, brightness and alpha and just use Hue you'll get all the colours in order.

    Check out the wiki for HSB for more information.

    for (float hsb = 0; hsb <= 1.0f; hsb += divisor) {
                 UIColor *color = [UIColor colorWithHue:hsb saturation:1.0f brightness:1.0f alpha:.5f];
                [retVal addObject:color];
    }
    

提交回复
热议问题