//
//  BaseViewController.swift
//  RainbowPlanet
//
//  Created by 南鑫林 on 2019/3/8.
//  Copyright © 2019 南鑫林. All rights reserved.
//

import UIKit

class BaseViewController: UIViewController {

    lazy var navigationBar = WRCustomNavigationBar.CustomNavigationBar()

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationController?.navigationBar.isHidden = true
        automaticallyAdjustsScrollViewInsets = false
        view.backgroundColor = .white
        if #available(iOS 11.0, *) {
            UIScrollView.appearance().contentInsetAdjustmentBehavior =  .automatic
        } else {
            if self.responds(to: #selector(setter: self.automaticallyAdjustsScrollViewInsets)) {
                self.automaticallyAdjustsScrollViewInsets = true
            }
        }
        setupNavigationBar()
    }

    fileprivate func setupNavigationBar()
    {
        navigationBar.wr_setBottomLineHidden(hidden: true)
        navigationBar.barBackgroundColor = UIColor.green
        navigationBar.titleLabelColor = .red
        if self.navigationController?.children.count != 1 {
            navigationBar.wr_setLeftButton(image: UIImage(named: "navigaitionbar_back_white")!)
        }
        view.addSubview(navigationBar)
    }

    @objc fileprivate func back()
    {
        navigationController?.popViewController(animated: true)
    }

}
