Fableon/Fableon/Object/Base/Extension/UINavigationBar+FAAdd.swift
2025-10-23 16:54:27 +08:00

50 lines
1.5 KiB
Swift

//
// UINavigationBar+FAAdd.swift
// Fableon
//
// Created by on 2025/10/9.
//
import UIKit
extension UINavigationBarAppearance {
static func defaultAppearance() -> UINavigationBarAppearance {
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.configureWithOpaqueBackground()
navBarAppearance.backgroundColor = .clear
navBarAppearance.backgroundEffect = nil
navBarAppearance.shadowColor = UIColor.clear
navBarAppearance.titleTextAttributes = [
NSAttributedString.Key.font : UIFont.font(ofSize: 18, weight: .bold),
NSAttributedString.Key.foregroundColor : UIColor.FFFFFF
]
return navBarAppearance
}
}
extension UINavigationBar {
func fa_setTranslucent(isTranslucent: Bool) {
self.isTranslucent = isTranslucent
}
func fa_setBackgroundColor(backgroundColor: UIColor?) {
let appearance = self.standardAppearance
appearance.backgroundColor = backgroundColor
self.standardAppearance = appearance
self.scrollEdgeAppearance = appearance
}
func fa_setTitleTextAttributes(titleTextAttributes: [NSAttributedString.Key : Any]?) {
let appearance = self.standardAppearance
if let titleTextAttributes = titleTextAttributes {
appearance.titleTextAttributes = titleTextAttributes
}
self.scrollEdgeAppearance = appearance
self.standardAppearance = appearance
}
}