Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //: A UIKit based Playground for presenting user interface
- import UIKit
- import PlaygroundSupport
- final class MyViewController: UIViewController {
- override func loadView() {
- let view = UIView()
- view.backgroundColor = .white
- let label = UILabel()
- label.frame = CGRect(x: 150, y: 200, width: 200, height: 20)
- label.text = "Hello World!"
- label.textColor = .black
- view.addSubview(label)
- self.view = view
- }
- override func viewDidLoad() {
- super.viewDidLoad()
- // Setup self as oberver for UIApplication.didBecomeActiveNotification notification name
- NotificationCenter.default.addObserver(self,
- selector: #selector(appDidBecomeActive),
- name: UIApplication.didBecomeActiveNotification, object: nil)
- }
- // That function runs when app will be active
- @objc private func appDidBecomeActive() {
- print("UIApplication is active now")
- }
- }
- // Present the view controller in the Live View window
- PlaygroundPage.current.liveView = MyViewController()
Add Comment
Please, Sign In to add comment