I want to display the mail ID in my view such that clicking the mail ID should open the mail composer view.
I want to display the button text as underlined to show i
Swift 3.2
if let title = button.titleLabel?.text, title != "" {
let attributeString = NSMutableAttributedString(string: title)
attributeString.addAttribute(NSAttributedStringKey.underlineStyle, value: 1, range: NSMakeRange(0, title.count))
button.titleLabel?.attributedText = attributeString
}
Objective C
NSString *tem = self.myButton.titleLabel.text;
if (tem != nil && ![tem isEqualToString:@""]) {
NSMutableAttributedString *temString=[[NSMutableAttributedString alloc]initWithString:tem];
[temString addAttribute:NSUnderlineStyleAttributeName
value:[NSNumber numberWithInt:1]
range:(NSRange){0,[temString length]}];
self.myButton.titleLabel.attributedText = temString;
}