Just trying to add a UILabel using SnapKit autolayout. The code i'm using is as follows:
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .lightGray
let userNameLabel = UILabel()
userNameLabel.text = "Dinesh nagarajan"
userNameLabel.backgroundColor = .white
self.view.addSubview(userNameLabel)
userNameLabel.snp.makeConstraints { (make) in
make.top.leading.trailing.height.equalTo(40)
}
}
Here i have mentioned the constraints for leading and trailing equals to 40. But the result i'm getting is different than the code. I have attached the image for reference to the code above. Why is it behaving differently than expected...?