Skip to content

Instantly share code, notes, and snippets.

@agiokas
Last active March 23, 2021 22:39
Show Gist options
  • Select an option

  • Save agiokas/eb88f53863e011d8812757db02c35ea6 to your computer and use it in GitHub Desktop.

Select an option

Save agiokas/eb88f53863e011d8812757db02c35ea6 to your computer and use it in GitHub Desktop.
//
// Created by Apostolos Giokas on 23.03.21.
//
import UIKit
class ViewController: UIViewController, IViewControllerNavigator {
let button1 = UIButton(frame: CGRect(x: 50, y: 100, width: 200, height: 45))
let button2 = UIButton(frame: CGRect(x: 50, y: 200, width: 200, height: 45))
let button3 = UIButton(frame: CGRect(x: 50, y: 300, width: 200, height: 45))
override func viewDidLoad() {
super.viewDidLoad()
[button1, button2, button3].enumerated().forEach { (idx, button) in
view.addSubview(button)
button.setTitle("Button \(idx + 1)", for: .normal)
button.setTitleColor(.black, for: .normal)
button.backgroundColor = .cyan
}
button1.addAction(UIAction(handler: { [weak self] _ in
self?.navigate(data: Data1(title: "Hello World"))
}), for: .touchUpInside)
button2.addAction(UIAction(handler: { [weak self] _ in
self?.navigate(data: Data1(title: "Again"))
}), for: .touchUpInside)
button3.addAction(UIAction(handler: { [weak self] _ in
self?.navigate(data: Data2(color: UIColor.red))
}), for: .touchUpInside)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment