//
//  RootVC.swift
//  Funny_sounds
//
//  Created by 忆海16 on 2024/8/14.
//

import UIKit
import SnapKit

class RootVC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        setNavigtionContrilerBase()
    }
    
    //设置导航栏属性
    func setNavigtionContrilerBase(){
        self.navigationController?.navigationBar.barTintColor = .white
        let titleTextAttributes = [
            NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16, weight: .bold),
            NSAttributedString.Key.foregroundColor: UIColor.black
        ]

        ///控制导航栏的背景颜色和底部线的隐藏
        if #available(iOS 13.0, *) {
            let appearance = UINavigationBarAppearance()
            appearance.configureWithOpaqueBackground() //重置导航栏背景颜色和阴影
            appearance.backgroundColor = UIColor.white
            appearance.shadowImage = UIImage()
            appearance.shadowColor = nil
            appearance.titleTextAttributes = titleTextAttributes
            self.navigationController?.navigationBar.standardAppearance = appearance
            self.navigationController?.navigationBar.scrollEdgeAppearance = appearance
        } else {
            
            self.navigationController?.navigationBar.barTintColor = UIColor.white
            self.navigationController?.navigationBar.titleTextAttributes = titleTextAttributes
            self.navigationController?.navigationBar.shadowImage = UIImage()
            self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
        }

    }
    
    
    //设置导航栏透明
    func setNavigationCotrollerHide(){
        // 1.设置导航栏半透明
        self.navigationController?.navigationBar.isTranslucent = false
        self.navigationController?.navigationBar.barTintColor = .clear
        // 2.设置导航栏背景图片
        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
        
        // 3.设置导航栏阴影图片
        self.navigationController?.navigationBar.shadowImage = UIImage()
    }
    
    override var preferredStatusBarStyle : UIStatusBarStyle {
        return .lightContent
    }

}
