iosswifttttattributedlabel

Getting a TTTAttributedLabel to print bold


Trying to use the TTTAttributedLabel framework for the first time. I want to use it to make part of my UILabel printed in a bold font and the other part printed light font:

let messageLabelString = "\(notificationSenderName) would like to rent your \(notificationItem). Approve?"
cell.messageLabel.text = messageLabelString
let nsString = messageLabelString as NSString
let range = nsString.rangeOfString(notificationSenderName)
let url = NSURL(string: "test")
cell.messageLabel.addLinkToURL(url, withRange: range)
cell.messageLabel.delegate = self

This is what it looks like right now:

enter image description here

I however don't want the blue and underlined font I just want to get a black and bold font. How do I do this?


Solution

  • Was able to do what I wanted through:

    let messageLabelString = "\(notificationSenderName) would like to rent your \(notificationItem). Approve?"
                cell.messageLabel.text = messageLabelString
                let nsString = messageLabelString as NSString
                let range = nsString.rangeOfString(notificationSenderName)
                let url = NSURL(string: "test")
    
                let subscriptionNoticeLinkAttributes = [
                    NSFontAttributeName: UIFont(name:"JohnstonITCPro-Bold", size:15)!
                    ]
    
                cell.messageLabel.linkAttributes = subscriptionNoticeLinkAttributes
                cell.messageLabel.addLinkToURL(url, withRange: range)
                cell.messageLabel.delegate = self