UILabel как сделать внутренние отступы
Как сделать у UILabel, как на картинке ниже? Сейчас пробую делать так, но не работает.
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let label = UILabel()
label.text = "Hello World"
label.backgroundColor = .black
label.textColor = .white
label.layer.masksToBounds = true
label.layer.cornerRadius = 8.0
label.bounds.inset(by: UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50))
view.addSubview(label)
}
}
Источник: Stack Overflow на русском