Here, we have a variable called buttonColor which may have any string with color name, for instance “blue”,”black”,”red” and we are going to set the UIButton title color based on buttonColor given
SEL colorSel = NSSelectorFromString([NSString stringWithFormat:@"%@Color", buttonColor]);
UIColor* tColor = nil;
if ([UIColor respondsToSelector:colorSel]){
tColor = [UIColor performSelector:colorSel];
} else {
tColor = whiteColor;
}
[button setTitleColor:tColor forState:UIControlStateNormal];