54 lines
1.7 KiB
Swift
54 lines
1.7 KiB
Swift
//
|
|
// UINavigationBar+NRAdd.swift
|
|
// ReaderHive
|
|
//
|
|
// Created by 湖北秦九 on 2025/11/25.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
extension UINavigationBar {
|
|
|
|
static let titleFont = UIFont.font(ofSize: 16, weight: .semibold)
|
|
static let titleWhiteColor = UIColor.white
|
|
static let titleBlackColor = UIColor.black
|
|
|
|
static func defaultAppearance() -> UINavigationBarAppearance {
|
|
let navBarAppearance = UINavigationBarAppearance()
|
|
navBarAppearance.configureWithOpaqueBackground()
|
|
navBarAppearance.backgroundColor = .clear
|
|
navBarAppearance.backgroundEffect = nil
|
|
navBarAppearance.shadowColor = UIColor.clear
|
|
navBarAppearance.titleTextAttributes = [
|
|
NSAttributedString.Key.font : UINavigationBar.titleFont,
|
|
NSAttributedString.Key.foregroundColor : UINavigationBar.titleWhiteColor
|
|
]
|
|
return navBarAppearance
|
|
}
|
|
}
|
|
|
|
extension UINavigationBar {
|
|
|
|
|
|
func nr_setTranslucent(isTranslucent: Bool) {
|
|
self.isTranslucent = isTranslucent
|
|
}
|
|
|
|
func nr_setBackgroundColor(backgroundColor: UIColor?) {
|
|
let appearance = self.standardAppearance
|
|
appearance.backgroundColor = backgroundColor
|
|
self.standardAppearance = appearance
|
|
self.scrollEdgeAppearance = appearance
|
|
}
|
|
|
|
func nr_setTitleTextAttributes(titleTextAttributes: [NSAttributedString.Key : Any]?) {
|
|
let appearance = self.standardAppearance
|
|
|
|
if let titleTextAttributes = titleTextAttributes {
|
|
appearance.titleTextAttributes = titleTextAttributes
|
|
}
|
|
self.scrollEdgeAppearance = appearance
|
|
self.standardAppearance = appearance
|
|
}
|
|
}
|