Last active
January 13, 2020 17:02
-
-
Save aainaj/a85baa708374ae47dfbf75a0464e0de0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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