Skip to content

Instantly share code, notes, and snippets.

@aainaj
Last active January 13, 2020 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aainaj/a85baa708374ae47dfbf75a0464e0de0 to your computer and use it in GitHub Desktop.
Save aainaj/a85baa708374ae47dfbf75a0464e0de0 to your computer and use it in GitHub Desktop.
import UIKit
class ListViewController: UIViewController {
let label = UILabel(frame: CGRect(x: 100, y: 200, width: 300, height: 50))
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
label.text = "Animating"
view.addSubview(label)
let controller = DetailViewController()
controller.definesPresentationContext = true
let navControll = UINavigationController(rootViewController: controller)
self.navigationController?.present(navControll, animated: true, completion: nil)
NotificationCenter.default.addObserver(forName: .titleUpdated, object: nil, queue: nil) {_ in
UIView.animate(withDuration: 0.3, animations: {
self.label.textColor = .green
})
}
}
deinit {
print("Deinit")
}
}
class DetailViewController: UIViewController {
var listTitle: (() -> String)?
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.post(name: .titleUpdated, object: nil)
}
}
extension Notification.Name {
static let titleUpdated = Notification.Name("titleUpdated")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment