Try this code (sorry for formatting, written on phone...)
NSDictionary *linkAttributes = @{[NSNumber numberWithInt:kCTUnderlineStyleNone] : (id)kCTUnderlineStyleAttributeName};
self.label.linkAttributes = linkAttributes;
Question
I am using TTTAttributedLabel (https://github.com/twotoasters/TTTAttributedLabel). Here I'm correctly getting the label with some clickable text.
I need to display my text like the username in above image(ie. without underline).How could I do that?
Solution
Try this code (sorry for formatting, written on phone...)
NSDictionary *linkAttributes = @{[NSNumber numberWithInt:kCTUnderlineStyleNone] : (id)kCTUnderlineStyleAttributeName};
self.label.linkAttributes = linkAttributes;
OTHER TIPS
For swift 4.0
let LinkAttributes = NSMutableDictionary(dictionary: testLink.linkAttributes)
LinkAttributes[NSAttributedStringKey.underlineStyle] = NSNumber(value: false)
yourLabel.linkAttributes = LinkAttributes as NSDictionary as! [AnyHashable: Any]
if you are already having label with underline style and if you want to remove it programatically use the following code
let string = "your text"
let attributes: [NSAttributedString.Key: Any] = [
.font: UIFont.systemFont(ofSize: 13)
]
let attributedString = NSAttributedString(string: string,
attributes: attributes)
yourLabel.attributedText = attributedString