I create dialog with custom button UIButton in swift IOS. How can change UIButton size programmatically.
class SuccessMessageView: UIView, UITextFieldDelegate {
private var buttonConfirm : UIButton = {
let button = UIButton()
button.setTitle("Ok", for: .normal)
button.backgroundColor = UIColor(rgb: PreferenceManager.shared.hasDevice() ? purpleColour : orangeColour)
button.setTitleColor(.white, for: .normal)
button.layer.cornerRadius = 10
button.addTarget(self, action: #selector(confirmFunc), for: .touchDown)
button.translatesAutoresizingMaskIntoConstraints = false
button.widthAnchor.constraint(equalToConstant: 140.0).isActive = true
button.frame.size.width = 140
return button
}
}
3
Answers
I found the solution for set UIButton width and height programatically like that set with constant.
Could you try this? Just remove the frame-related lines.