- (NSDictionary *)getColorName:(NSString *)colorCode {
NSString * path = [[NSBundle mainBundle] pathForResource:@"named-web-colors" ofType:@"js"];
NSData * jsData = [[NSData alloc]initWithContentsOfFile:path];
NSString * jsCode = [[NSString alloc]initWithData:jsData encoding:NSUTF8StringEncoding];
NSString * finiString = [NSString stringWithFormat:@"%@", jsCode];
self.jsContext = [[JSContext alloc]init];
[self.jsContext evaluateScript:finiString];
JSValue *jsValue = [self.jsContext evaluateScript:[NSString stringWithFormat:@"getColorName('%@')",colorCode]];
return jsValue.toDictionary;
}
发表回复