随机颜色的产生

1.产生随机颜色:

 

-(UIColor *)randomColor{  //产生随机颜色

    static BOOL seed = NO;

    if (!seed) {

        seed = YES;

        srandom(time(NULL));

    }

    CGFloat red = (CGFloat)random()/(CGFloat)RAND_MAX;

    CGFloat green = (CGFloat)random()/(CGFloat)RAND_MAX;

    CGFloat blue = (CGFloat)random()/(CGFloat)RAND_MAX;

    return [UIColor colorWithRed:red green:green blue:blue alpha:1.0f];//alpha为1.0,颜色完全不透明

}

 

你可能感兴趣的:(随机)