Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert nsstring to uicolor?

Tags:

iphone

I have one string(NSString) in string there is one value like string=@"black" now i want to use textcolore using string.I have written below code. txtView.textColor=[UIColor string];

But it not working can suggest me?

like image 767
MD. Avatar asked Jan 08 '10 11:01

MD.


1 Answers

You can get selector using NSSelectorFromString function and then send it to UIColor. You must also test if UIColor is able to respond to the selector you have to avoid error:

SEL blackSel = NSSelectorFromString(@"blackColor");
UIColor* tColor = nil;
if ([UIColor respondsToSelector: blackSel])
      tColor  = [UIColor performSelector:blackSel];
like image 121
Vladimir Avatar answered Sep 22 '22 15:09

Vladimir