swift uibutton programmatically set ontap function
myButton.addTarget(self, action: #selector(myButtonTapped), for: .touchUpInside)
@objc func myButtonTapped() {
print("My button was tapped!")
}
swift uibutton programmatically set ontap function
myButton.addTarget(self, action: #selector(myButtonTapped), for: .touchUpInside)
@objc func myButtonTapped() {
print("My button was tapped!")
}
how to create button action programmatically in ios
let button = UIButton(type: UIButtonType.System) as UIButton
button.frame = CGRectMake(100, 100, 100, 50)
button.backgroundColor = UIColor.greenColor()
button.setTitle("Test Button", forState: UIControlState.Normal)
self.view.addSubview(button)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us