The UI gives the diagram a #f2f2f2 let me set. There's no RGB you want. So you can only fix the code yourself.
HexColors.h
#import"TargetConditionals.h"#ifTarget_os_iphone | | Target_iphone_simulator#import<UIKit/UIKit.h>#defineHxcolor Uicolor#else#import<Cocoa/Cocoa.h>#defineHxcolor NSColor#endif@interface Hxcolor (hexcoloraddition)+ (Hxcolor *) hx_colorwithhexstring: (NSString *) hexstring;+ (Hxcolor *) hx_colorwithhexstring: (NSString *) hexstring Alpha: (cgfloat) Alpha;+ (Hxcolor *) hx_colorwith8bitred: (Nsinteger) Red Green: (Nsinteger) Green Blue: (Nsinteger) Blue;+ (Hxcolor *) hx_colorwith8bitred: (Nsinteger) Red Green: (Nsinteger) Green Blue: (Nsinteger) Blue Alpha: (cgfloat) Alpha; @end
Hexcolors.m
#import"HexColors.h"@implementation Hxcolor (hexcoloraddition)+ (Hxcolor *) hx_colorwithhexstring: (NSString *) hexstring{//Check for hash and add the missing hash if('#'! = [HexString characteratindex:0]) {hexstring= [NSString stringWithFormat:@"#%@", hexstring]; } cgfloat Alpha=1.0; if(5= = Hexstring.length | |9==hexstring.length) {nsstring* Alphahex = [hexstring substringwithrange:nsmakerange (1,9= = Hexstring.length?2:1)]; if(1= = alphahex.length) Alphahex = [NSString stringWithFormat:@"%@%@", Alphahex, Alphahex]; HexString= [NSString stringWithFormat:@"#%@", [hexstring Substringfromindex:9= = Hexstring.length?3:2]]; unsigned Alpha_u= [[Selfclass] Hx_hexvaluetounsigned:alphahex]; Alpha= ((cgfloat) Alpha_u)/255.0; } return[Selfclass] hx_colorwithhexstring:hexstring Alpha:alpha];}+ (Hxcolor *) hx_colorwithhexstring: (NSString *) hexstring Alpha: (cgfloat) alpha{if(Hexstring.length = =0) { returnNil; } //Check for hash and add the missing hash if('#'! = [HexString characteratindex:0]) {hexstring= [NSString stringWithFormat:@"#%@", hexstring]; } //Check for string length if(7! = Hexstring.length &&4!=hexstring.length) {nsstring*defaulthex = [NSString stringWithFormat:@"0xFF"]; unsigned defaultint= [[Selfclass] Hx_hexvaluetounsigned:defaulthex]; Hxcolor*color = [Hxcolor hx_colorwith8bitred:defaultint green:defaultint blue:defaultint Alpha:1.0]; returncolor; } //Check for 3 character hexstringshexstring = [Selfclass] hx_hexstringtransformfromthreecharacters:hexstring]; NSString*redhex = [NSString stringWithFormat:@"0x%@", [HexString Substringwithrange:nsmakerange (1,2)]]; unsigned redint= [[Selfclass] Hx_hexvaluetounsigned:redhex]; NSString*greenhex = [NSString stringWithFormat:@"0x%@", [HexString Substringwithrange:nsmakerange (3,2)]]; unsigned greenint= [[Selfclass] Hx_hexvaluetounsigned:greenhex]; NSString*bluehex = [NSString stringWithFormat:@"0x%@", [HexString Substringwithrange:nsmakerange (5,2)]]; unsigned blueint= [[Selfclass] Hx_hexvaluetounsigned:bluehex]; Hxcolor*color =[Hxcolor hx_colorwith8bitred:redint green:greenint blue:blueint Alpha:alpha]; returncolor;}+ (Hxcolor *) hx_colorwith8bitred: (Nsinteger) Red Green: (Nsinteger) Green Blue: (nsinteger) blue{return[Selfclass] hx_colorwith8bitred:red green:green Blue:blue Alpha:1.0];}+ (Hxcolor *) hx_colorwith8bitred: (Nsinteger) Red Green: (Nsinteger) Green Blue: (Nsinteger) Blue Alpha: (cgfloat) alpha{Hxcolor *color =Nil;#if(Target_iphone_simulator | | Target_os_iphone)Color= [Hxcolor colorwithred: (float) red/255Green: (float) green/255Blue: (float) blue/255Alpha:alpha];#elseColor= [Hxcolor colorwithcalibratedred: (float) red/255Green: (float) green/255Blue: (float) blue/255Alpha:alpha];#endif returncolor;}+ (NSString *) Hx_hexstringtransformfromthreecharacters: (NSString *) hexstring{if(Hexstring.length = =4) {hexstring= [NSString stringWithFormat:@"#%1$c%1$c%2$c%2$c%3$c%3$c", [hexstring characteratindex:1], [hexstring characteratindex:2], [hexstring characteratindex:3]]; } returnhexstring;}+ (unsigned) hx_hexvaluetounsigned: (NSString *) hexvalue{unsigned value=0; Nsscanner*hexvaluescanner =[Nsscanner Scannerwithstring:hexvalue]; [Hexvaluescanner scanhexint:&value]; returnvalue;} @end
Call
Self.backgroundcolor = [Hxcolor hx_colorwithhexstring:@ "ff5a60"];
IOS settings #ffff this color