Я реализую анимацию в swift 5, используя решение в , пытаясь анимировать ограничение в swift
let textView = UITextView()
lazy var heightConstraint = textView.heightAnchor.constraint(equalToConstant: 0)
@IBAction func actionBtnOpcaoA(_ sender: Any) {
heightConstraint.constant = heightConstraint.constant == 0 ? 50 : 0
UIView.animate(withDuration: 2) {
self.view.layoutIfNeeded()
}
}
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
view.addSubview(textView)
textView.backgroundColor = .orange
textView.text = "Tente novamente !"
textView.allowsEditingTextAttributes = true
textView.translatesAutoresizingMaskIntoConstraints = false
textView.topAnchor.constraint(equalToSystemSpacingBelow: view.layoutMarginsGuide.topAnchor, multiplier: 1).isActive = true
textView.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor).isActive = true
textView.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor).isActive = true
heightConstraint.isActive = true
}
, когда я нажимаю кнопку actionBtnOpcaoA, она запускает анимацию. Хорошо. Но размер шрифта текста "Tente novamente!" слишком мала и не централизована. Как я могу увеличить размер шрифта и централизовать сообщение?