I created custom button subclassing UIButton. I set custom font for titleLabel.
After tapping on custom button, the part of title disappears.
Without setting custom font, the text stays the same.
I think this problem only occures with devices targeting ios >= 13.
Before tap ->
After tap ->
//BasicButton class
class BasicButton: UIButton {
override init(frame: CGRect) {
super.init(frame: frame)
titleLabel?.font = UIFont.proximaNovaBold.withSize(20.0)
layoutIfNeeded()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
titleLabel?.font = UIFont.proximaNovaBold.withSize(20.0)
layoutIfNeeded()
}
override func layoutSubviews() {
super.layoutSubviews()
titleLabel?.font = UIFont.proximaNovaBold.withSize(20.0)
layoutIfNeeded()
}
override func setTitle(_ title: String?, for state: UIControl.State) {
super.setTitle(title, for: state)
titleLabel?.font = UIFont.proximaNovaBold.withSize(20.0)
layoutIfNeeded()
}
}
//extension UIFont
@nonobjc class var proximaNovaBold: UIFont {
return UIFont(name: "ProximaNova-Bold", size: 17.0)!
}
//BasicButton storyboard properties
]
changing Style of the button from Plain to Default was solution for the problem