Created
October 20, 2019 06:10
-
-
Save JunyuKuang/3ecc7c9374c0ba67438c9a6d06612e36 to your computer and use it in GitHub Desktop.
Revisions
-
JunyuKuang created this gist
Oct 20, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ // // ViewController.swift // UIKitAccentColor // // Created by Jonny Kuang on 10/20/19. // Copyright © 2019 Jonny Kuang. All rights reserved. // import UIKit class ViewController: UIViewController { #if targetEnvironment(macCatalyst) override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .kjy_controlAccentColor NotificationCenter.default.addObserver(self, selector: #selector(systemColorsDidChange), name: .init("NSSystemColorsDidChangeNotification"), object: nil) } @objc private func systemColorsDidChange() { print(#function) view.backgroundColor = .kjy_controlAccentColor } #endif } extension UIColor { #if targetEnvironment(macCatalyst) static var kjy_controlAccentColor: UIColor! { UIColor.value(forKey: "controlAccentColor") as? UIColor } #endif }