how to convert nsstring to uicolor?

前端 未结 1 1367
暗喜
暗喜 2020-12-10 06:01

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=[UICol

相关标签:
1条回答
  • 2020-12-10 06:30

    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];
    
    0 讨论(0)
提交回复
热议问题