篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift Swift - UIViewController的类扩展相关的知识,希望对你有一定的参考价值。
Source: BorgGreen
01. Create a new class...
import UIKit
class BaseViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// self.navigationController?.navigationBar.isTranslucent = true
//
// self.navigationController?.navigationBar.barTintColor = UIColor.white //user global variable for text
// self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.black]//user global variable
//
// self.navigationController?.navigationBar.barStyle = UIBarStyle.black //user global variable
// self.navigationController?.navigationBar.tintColor = UIColor.black //user global variable
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
02. Extend your normal classes this way to inherit the changes
import UIKit
class ViewController: BaseViewController { ... }
以上是关于swift Swift - UIViewController的类扩展的主要内容,如果未能解决你的问题,请参考以下文章