Guest User

Untitled

a guest
Nov 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. //: A UIKit based Playground for presenting user interface
  2.  
  3. import UIKit
  4. import PlaygroundSupport
  5.  
  6. final class MyViewController: UIViewController {
  7.  
  8. override func loadView() {
  9. let view = UIView()
  10. view.backgroundColor = .white
  11.  
  12. let label = UILabel()
  13. label.frame = CGRect(x: 150, y: 200, width: 200, height: 20)
  14. label.text = "Hello World!"
  15. label.textColor = .black
  16.  
  17. view.addSubview(label)
  18. self.view = view
  19. }
  20.  
  21. override func viewDidLoad() {
  22. super.viewDidLoad()
  23.  
  24. // Setup self as oberver for UIApplication.didBecomeActiveNotification notification name
  25. NotificationCenter.default.addObserver(self,
  26. selector: #selector(appDidBecomeActive),
  27. name: UIApplication.didBecomeActiveNotification, object: nil)
  28. }
  29.  
  30. // That function runs when app will be active
  31. @objc private func appDidBecomeActive() {
  32. print("UIApplication is active now")
  33. }
  34.  
  35. }
  36. // Present the view controller in the Live View window
  37. PlaygroundPage.current.liveView = MyViewController()
Add Comment
Please, Sign In to add comment