Below code is used to add UIButton dynamically:
var signUpButton : UIButton = {
let signInButton = UIButton()
signInButton.setTitle(LocalizationManager.shared.localString(for: LocalizableStrings.signUpButton), for: .normal)
signInButton.setTitleColor(.white, for: .normal)
signInButton.setTitleColor(Colors.initoDark.withAlphaComponent(0.2), for: .highlighted)
signInButton.backgroundColor = Colors.initoGreen
signInButton.titleLabel?.font = UIFont.montserratSemiBold(15)
signInButton.layer.cornerRadius = 26
signInButton.layer.borderWidth = 2
signInButton.layer.borderColor = Colors.initoGreen.cgColor
signInButton.addTarget(self, action: #selector(handleSignupButtonTapped), for: .touchUpInside)
return signInButton
}()
But in some phones with iOS 15 update(15.0.1, 15.0.2, 15.1), button click is not responding at all.