一、保存dom
CGFloat a = random()%255/255.0;spa
CGFloat b = random()%255/255.0;string
CGFloat c = random()%255/255.0;it
UIColor *textDefaultColor = [UIColor colorWithRed:a green:b blue:c alpha:1 ];io
CGColorRef colorRef = textDefaultColor.CGColor;class
NSString *colorStr = [CIColor colorWithCGColor:colorRef].stringRepresentation;object
[[NSUserDefaults standardUserDefaults] setObject:colorStr forKey:@"color"];view
[[NSUserDefaults standardUserDefaults] synchronize];vi
二、讀取co
NSString *colorStr = [[NSUserDefaults standardUserDefaults] objectForKey:@"color"];
CIColor *colorRef = (CIColor *)[CIColor colorWithString:colorStr];
self.view.backgroundColor = [UIColor colorWithCIColor:colorRef];