I am having a problem where a UIButton is changingit's width if I add anotherbuttoninside the sameview`.
This is how it looks without the 2nd button:
and this is how it looks if I constrain the 2nd button (title: "Wishlist?") inside the same view:
This is how I create the rounded image button:
let wishButton: UIButton = {
let v = UIButton()
v.setBackgroundImage(UIImage(named: "wishButton"), for: .normal)
v.translatesAutoresizingMaskIntoConstraints = false
v.addTarget(self, action: #selector(wishButtonTapped), for: .touchUpInside)
v.contentVerticalAlignment = .fill
v.contentHorizontalAlignment = .fill
return v
}()
// constrain wishButton
wishButton.centerXAnchor.constraint(equalTo: popUpView.centerXAnchor).isActive = true
wishButton.centerYAnchor.constraint(equalTo: popUpView.centerYAnchor, constant: 70).isActive = true
wishButton.heightAnchor.constraint(equalToConstant: 72).isActive = true
wishButton.widthAnchor.constraint(equalToConstant: 72).isActive = true
2nd button with title:
let dropDownButton: dropDownBtn = {
let v = dropDownBtn()
v.setTitle("Wishlist?", for: .normal)
v.translatesAutoresizingMaskIntoConstraints = false
return v
}()
// constrain dropDownButton
dropDownButton.centerXAnchor.constraint(equalTo: popUpView.centerXAnchor).isActive = true
dropDownButton.centerYAnchor.constraint(equalTo: popUpView.centerYAnchor).isActive = true
wishButton.heightAnchor.constraint(equalToConstant: 100).isActive = true
wishButton.widthAnchor.constraint(equalToConstant: 40).isActive = true

