62 lines
1.8 KiB
Swift
62 lines
1.8 KiB
Swift
//
|
||
// SRNavigationController.swift
|
||
// SynthReel
|
||
//
|
||
// Created by 澜声世纪 on 2025/11/13.
|
||
// Copyright © 2025 SR. All rights reserved.
|
||
//
|
||
|
||
import UIKit
|
||
|
||
class SRNavigationController: UINavigationController {
|
||
|
||
override func viewDidLoad() {
|
||
super.viewDidLoad()
|
||
|
||
// Do any additional setup after loading the view.
|
||
}
|
||
|
||
|
||
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
|
||
if children.count > 0 {
|
||
viewController.hidesBottomBarWhenPushed = true
|
||
}
|
||
super.pushViewController(viewController, animated: animated)
|
||
}
|
||
|
||
override func setViewControllers(_ viewControllers: [UIViewController], animated: Bool) {
|
||
for (index, value) in viewControllers.enumerated() {
|
||
if index != 0 {
|
||
value.hidesBottomBarWhenPushed = true
|
||
}
|
||
}
|
||
super.setViewControllers(viewControllers, animated: animated)
|
||
}
|
||
|
||
}
|
||
|
||
extension UINavigationController {
|
||
|
||
func uv_setNavigationBarTransparent(_ transparent: Bool) {
|
||
if transparent {
|
||
self.navigationBar.setBackgroundImage(UIImage(), for: .default)
|
||
self.navigationBar.shadowImage = UIImage()
|
||
self.navigationBar.isTranslucent = true
|
||
} else {
|
||
self.navigationBar.setBackgroundImage(nil, for: .default)
|
||
self.navigationBar.shadowImage = nil
|
||
self.navigationBar.isTranslucent = false
|
||
}
|
||
}
|
||
}
|
||
|
||
extension UINavigationController {
|
||
|
||
func sr_setNavigationTitle(_ title: String?, for viewController: UIViewController) {
|
||
let titleText = title ?? ""
|
||
// 复用你的自定义标题视图(左右图片 + 文本)
|
||
let titleView = SRNavgationTitleView(title: titleText)
|
||
viewController.navigationItem.titleView = titleView
|
||
}
|
||
}
|