I have a UIButton class with a NSMutableAttributedString as the title (for the formatting). I would like to now change the titleColor of the button text from my vc class because it has been'selected'.
I can do it fine as a normal button title. But as a NSMutableAttributedString - no dice.
Some questions/advice: As the custom class view is already a button - should my color update happen in that class - and not from the vc? Just tell it to update and bake the color in the custom class?
Do I expose the NSMutableAttributedString property for the button's title so that I can access from my VC and change the color? This way I could also pass in new text as well as a new color.
In my CircleButton m file
NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[style setAlignment:NSTextAlignmentCenter];
[style setLineBreakMode:NSLineBreakByWordWrapping];
UIFont *font1 = [UIFont fontWithName:@"Futura" size:20.0f];
NSDictionary *dict1 = @{NSUnderlineStyleAttributeName:@(NSUnderlineStyleNone),
NSFontAttributeName:font1,
NSForegroundColorAttributeName:textClr,
NSParagraphStyleAttributeName:style};
attributedTText = [[NSAttributedString alloc] initWithString:btnTxt attributes:dict1];
[[button titleLabel] setNumberOfLines:0];
[[button titleLabel] setLineBreakMode:NSLineBreakByWordWrapping];
[button setAttributedTitle:attributedTText forState:UIControlStateNormal];
[button setTitleColor:textClr forState:UIControlStateNormal];