Sunday, October 18, 2026
HomeiOS Developmentios - Change UIButton dimension programmatically in dialog in Swift

ios – Change UIButton dimension programmatically in dialog in Swift

[ad_1]

I create dialog with customized button UIButton in swift IOS. How can change UIButton dimension programmatically.

class SuccessMessageView: UIView, UITextFieldDelegate {

non-public var buttonConfirm : UIButton = {
    
    let button = UIButton()
    button.setTitle("Okay", for: .regular)
    button.backgroundColor = UIColor(rgb: PreferenceManager.shared.hasDevice() ? purpleColour : orangeColour)
    button.setTitleColor(.white, for: .regular)
    button.layer.cornerRadius = 10
    button.addTarget(self, motion: #selector(confirmFunc), for: .touchDown)
    
    button.translatesAutoresizingMaskIntoConstraints = false
    button.widthAnchor.constraint(equalToConstant: 140.0).isActive = true
    button.body.dimension.width = 140
    return button
}
}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments