67 lines
2.2 KiB
Swift
67 lines
2.2 KiB
Swift
//
|
|
// WP_RootVC.swift
|
|
// WallpaperHD_Live
|
|
//
|
|
// Created by 忆海16 on 2024/7/22.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class WP_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 = true
|
|
|
|
// 2.设置导航栏背景图片
|
|
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
|
|
|
|
// 3.设置导航栏阴影图片
|
|
self.navigationController?.navigationBar.shadowImage = UIImage()
|
|
}
|
|
|
|
|
|
// func setNavigationCotrollerOpaque(){
|
|
//
|
|
// }
|
|
override var preferredStatusBarStyle : UIStatusBarStyle {
|
|
return .lightContent
|
|
}
|
|
|
|
}
|