SynthReel/SynthReel/Base/ViewController/SRNavigationController.swift
2025-12-10 10:23:22 +08:00

62 lines
1.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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
}
}