//
Uicolor+transformation.h
Contactapp
//
Created by Gongdongdong on 15/9/11.
Copyright (c) year Lan technology . All rights reserved.
//
#import <UIKit/UIKit.h>
@interface Uicolor (transformation)
+ (Uicolor *) Transformat: (NSString *) colorstring;
@end
//
Uicolor+transformation.m
Contactapp
//
Created by Gongdongdong on 15/9/11.
Copyright (c) year Lan technology . All rights reserved.
//
#import "Uicolor+transformation.h"
@implementation Uicolor (transformation)
+ (Uicolor *) Transformat: (NSString *) colorstring {
// Remove hex # For example (#FFFFFF)
NSString *newcolorstring = [colorstring substringfromindex:1];
Nsrange r1 = {0,2};
Nsrange r2 = {2,2};
Nsrange R3 = {4,2};
NSString *redstr = [newcolorstring substringwithrange:r1];
NSString *greenstr = [newcolorstring substringwithrange:r2];
NSString *bluestr = [newcolorstring SUBSTRINGWITHRANGE:R3];
Colorblock ([redstr substringtoindex:1]);
int red = [Colorblock ([Redstr substringtoindex:1]) intvalue] * + [Colorblock ([Redstr] Substringfromindex:1]) intvalue];
int green = [Colorblock ([Greenstr substringtoindex:1]) intvalue] * + [Colorblock ([Greenstr] Substringfromindex:1]) intvalue];
int blue = [Colorblock ([Bluestr substringtoindex:1]) intvalue] * + [Colorblock ([ Bluestr Substringfromindex:1]) intvalue];
float r = red/ 255.0;
float g = green/ 255.0;
float b = blue/ 255.0;
Uicolor *c = [Uicolor colorwithred:r green:g blue:b Alpha:1.0];
return C;
}
NSString * (^colorblock) (NSString *) = ^ (NSString *str) {
if([str isequaltostring:@ "A"]) {
str = @ "ten";
}Else if ([str isequaltostring:@ "B"]) {
str = @ "one";
}Else if ([str isequaltostring:@ "C"]) {
str = @ "n";
}
Else if ([str isequaltostring:@ "D"]) {
str = @ "+";
}
Else if ([str isequaltostring:@ "E"]) {
str = @ "+";
}Else if ([str isequaltostring:@ "F"]) {
str = @ "";
}
return str;
};
@end
Hex color conversion to iOS can be used for Uicolor