Swift - UIViewController的类扩展

swift
阅读 47 收藏 0 点赞 0 评论 0

Swift - Class Extension of 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 { ... }
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号