IOS hexadecimal color to 10 hexadecimal color, ios hexadecimal color
 
+ (UIColor *) colorWithHexString :( NSString *) coloStr {
 
 
 
// Retrieve spaces and line breaks to uppercase
 
NSString * cString = [[coloStr stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet] uppercaseString];
 
 
If (cString. length <6 ){
 
Return [UIColor clearColor];
 
}
 
// Start
 
If ([cString hasPrefix: @ "0X"]) {
 
CString = [cString substringFromIndex: 2];
 
}
 
If ([cString hasPrefix: @ "#"]) {
 
CString = [cString substringFromIndex: 1];
 
}
 
If ([cString length]! = 6 ){
 
Return [UIColor clearColor];
 
}
 
// Truncate the string
 
Nsange range;
 
Range. location = 0;
 
Range. length = 2;
 
 
NSString * rString = [cString substringWithRange: range];
 
 
Range. location = 2;
 
NSString * gString = [cString substringWithRange: range];
 
 
Range. location = 4;
 
NSString * bString = [cString substringWithRange: range];
 
 
// Hexadecimal conversion
 
Unsigned int r, g, B;
 
 
[[Ns1_scannerwithstring: rString] scanHexInt: & r];
 
[[Ns1_scannerwithstring: gString] scanHexInt: & g];
 
[[Ns1_scannerwithstring: bString] scanHexInt: & B];
 
 
 
 
Return [UIColor colorWithRed :( (float) r/255.0f) green :( (float) g/255.0f) blue :( (float) B/255.0f) alpha: 1.0];
 
}