Advertisement
Guest User

Untitled

a guest
Jan 4th, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.59 KB | None | 0 0
  1.     override func viewDidLoad() {
  2.         super.viewDidLoad()
  3.         // Do any additional setup after loading the view, typically from a nib.
  4.  
  5.         let button = UIButton(type: .system)
  6.         button.setTitle("ahoj", for: .normal)
  7.         view.addSubview(button)
  8.         button.translatesAutoresizingMaskIntoConstraints = false
  9.         button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
  10.         button.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
  11.  
  12.         button.addAction(for: .touchUpInside) {
  13.             print("ahoj")
  14.         }
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement