UIColor-Random.m
上传用户:jjjjag8
上传日期:2017-04-17
资源大小:1443k
文件大小:1k
- //
- // NSColor-Random.m
- // QuartzFun
- //
- // Created by Jeff LaMarche on 7/31/08.
- // Copyright 2008 __MyCompanyName__. All rights reserved.
- //
- #import "UIColor-Random.h"
- @implementation UIColor(Random)
- +(UIColor *)randomColor
- {
- static BOOL seeded = NO;
- if (!seeded) {
- seeded = YES;
- srandom(time(NULL));
- }
- CGFloat red = (CGFloat)random()/(CGFloat)RAND_MAX;
- CGFloat blue = (CGFloat)random()/(CGFloat)RAND_MAX;
- CGFloat green = (CGFloat)random()/(CGFloat)RAND_MAX;
- return [UIColor colorWithRed:red green:green blue:blue alpha:1.0f];
- }
- @end