Issue :
I have use below code to change Title and set underline of UIButton at run time.
[btnTemp setTitle:@"Test" forState:UIControlStateNormal];
I have got below issues:
1. Underline is not showing
2. Title not change
3. Title color is display default black.
To overcome this issue I have implement below code:
NSDictionary *attribs = @{
NSForegroundColorAttributeName: _btnTemp.titleLabel.textColor,
NSFontAttributeName: _btnTemp.titleLabel.font,
NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)
};
NSAttributedString *strAttributed = [[NSAttributedString alloc] initWithString:@"Test" attributes:attribs];
[btnTemp setAttributedTitle:strAttributed forState:UIControlStateNormal];