I'm trying to create an action that will underline a button when pressed by replacing its current title with an attributed string. However, this keeps resulting in an "unrecognized selector sent to instance" error. I've connected one IBAction to this button, and created an IBOutlet weak variable referring to it. To my knowledge these should not interfere with one another.
Here is my code for the action connected to the button
@IBAction func voButtonTapped(_ sender: Any) {
let voString = "vo"
let attributedvo = NSAttributedString(string: voString, attributes: underlineAttribute)
vButton.setAttributedTitle(attributedvo, for: .normal)
}
and this is the error below:
[__SwiftValue set]: unrecognized selector sent to instance 0x600001584510
underlinedAttribute:
let underlineAttribute: [NSAttributedString.Key: Any] = [
.font: UIFont(name: "Rockwell-Bold", size: 35) as Any,
.foregroundColor: ColorManager.specialYellow,
.underlineStyle: NSUnderlineStyle.single.rawValue]
vButton:
@IBOutlet weak var vButton: UIButton!
ColorManager:
struct ColorManager {
static let specialYellow = Color("Special Yellow")
}