Size: a a a
A
extension UIView {
func show() {
let view = UILabel()
view.text = "TEST"
view.backgroundColor = .red
view.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(view)
let topConstraint = view.topAnchor.constraint(equalTo: self.topAnchor); topConstraint.isActive = true
view.heightAnchor.constraint(greaterThanOrEqualToConstant: 50).isActive = true
view.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 10).isActive = true
view.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -10).isActive = true
UIView.animate(withDuration: 3, animations: {
topConstraint.constant += self.safeAreaInsets.top + 10
self.layoutIfNeeded()
})
}
}
Р
extension UIView {
func show() {
let view = UILabel()
view.text = "TEST"
view.backgroundColor = .red
view.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(view)
let topConstraint = view.topAnchor.constraint(equalTo: self.topAnchor); topConstraint.isActive = true
view.heightAnchor.constraint(greaterThanOrEqualToConstant: 50).isActive = true
view.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 10).isActive = true
view.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -10).isActive = true
UIView.animate(withDuration: 3, animations: {
topConstraint.constant += self.safeAreaInsets.top + 10
self.layoutIfNeeded()
})
}
}
topConstraint.constant += self.safeAreaInsets.top + 10
вынеси наверх, за UIview.animate…DM
V
DM
DM
V