This is my convenience init for UIButton:
convenience init(underlinedTitle: String, font: UIFont, color: UIColor) {
var configuration = UIButton.Configuration.plain()
configuration.title = underlinedTitle
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
var outgoing = incoming
outgoing.font = font
outgoing.foregroundColor = color
outgoing.underlineStyle = .single
outgoing.underlineColor = color
return outgoing
}
self.init(configuration: configuration)
}
and the effect is following:
Why is it not underlined?
2
Answers
try use way from this answer
https://stackoverflow.com/a/41166179/11335258
Hmm… can’t find this documented anywhere, but appears to be correct.
To add underline style:
To remove underline style: