I've created a custom UILabel in order to be able to change its safe area so the text could have some padding and look nicer, but after I changed my safeArea the text still go all the way from edge to edge and no padding added here's my code
class customLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
setUp()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override var safeAreaInsets: UIEdgeInsets {
return UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
}
func setUp(){
lineBreakMode = NSLineBreakMode.byWordWrapping
numberOfLines = 0
textColor = UIColor.white
textAlignment = .center
layer.cornerRadius = 8
clipsToBounds = true
backgroundColor = UIColor.black.withAlphaComponent(0.7)
font = UIFont.boldSystemFont(ofSize: 20)
translatesAutoresizingMaskIntoConstraints = false
}
}
how to keep the text inside the new safeAreaInset?
thank you!