:
Code:
- (void) viewdidload{[Super Viewdidload]; //Do any additional setup after loading the view.UIView*view=[[uiview Alloc]initwithframe:cgrectmake ( -, -, $, $)]; View.backgroundcolor=[self colorwithhexstring:@"e26562"]; [Self.view Addsubview:view]; }//16 binary color #e26562 and Uicolor, set view background color-(Uicolor *) colorwithhexstring: (NSString *) color{NSString*cstring =[[Color Stringbytrimmingcharactersinset:[nscharacterset Whitespaceandnewlinecharacterset]] uppercaseString]; //String should be 6 or 8 characters if([cString Length] <6) { return[Uicolor Clearcolor]; } //strip 0X If it appears if([cString Hasprefix:@"0X"]) cString= [CString Substringfromindex:2]; if([cString Hasprefix:@"#"]) cString= [CString Substringfromindex:1]; if([cString length]! =6) return[Uicolor Clearcolor]; //separate into R, G, b substringsNsrange Range; Range.location=0; Range.length=2; //RNSString *rstring =[cString Substringwithrange:range]; //gRange.location =2; NSString*gstring =[cString Substringwithrange:range]; //bRange.location =4; NSString*bstring =[cString Substringwithrange:range]; //Scan ValuesUnsignedintR, G, B; [[Nsscanner scannerwithstring:rstring] Scanhexint:&R]; [[Nsscanner scannerwithstring:gstring] Scanhexint:&G]; [[Nsscanner scannerwithstring:bstring] Scanhexint:&b]; return[Uicolor colorwithred: ((float) R/255.0f) Green: ((float) G/255.0f) Blue: ((float) b/255.0f) Alpha:1.0f];}
16 binary color and Uicolor cross-turn