Untitled
unknown
plain_text
2 years ago
677 B
9
Indexable
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Create a button
let button = UIButton(type: .system)
button.setTitle("Click me", for: .normal)
button.frame = CGRect(x: 100, y: 100, width: 200, height: 40)
// Add a target to the button
button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside)
// Add the button to the view
view.addSubview(button)
}
// Function to handle button click
@objc func buttonClicked() {
print("Button clicked!")
}
}
Editor is loading...
Leave a Comment