have a problem with NSLayoutConstraint and .scaleAspectFill after applying logoView (positioning and scaling) and titleLabel constraints, titleLabel's Y position not sets correctly
titleLabel.topAnchor.constraint(equalTo: logoView.bottomAnchor, constant: 20])
here my sample:
let logoView:UIImageView = {
let img = UIImage(named: "big_logo")
let im = UIImageView(image: img)
im.translatesAutoresizingMaskIntoConstraints = false
im.contentMode = .scaleAspectFill
return im
}()
lazy var titleLabel:UILabel = {
let title:UILabel = UILabel()
title.translatesAutoresizingMaskIntoConstraints = false
title.text = MuiPack.getMuiString(key: "splash_greeting")
title.font = UIFont.boldSystemFont(ofSize: 18)
title.textColor = .black
return title
}()
NSLayoutConstraint.activate([logoView.widthAnchor.constraint(equalTo: self.view.widthAnchor, multiplier: 0.6),
logoView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
logoView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor, constant: -20)])
NSLayoutConstraint.activate([titleLabel.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
titleLabel.topAnchor.constraint(equalTo: logoView.bottomAnchor, constant: 20])