Files
comaps/iphone/Maps/Core/Theme/Renderers/UINavigationBarRenderer.swift
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

52 lines
1.6 KiB
Swift

extension UINavigationBar {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.navigationBar)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UINavigationBarRenderer.render(self, style: style)
}
}
}
class UINavigationBarRenderer: UIViewRenderer {
class func render(_ control: UINavigationBar, style: Style) {
super.render(control, style: style)
if let barTintColor = style.barTintColor {
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = barTintColor
control.standardAppearance = appearance
control.scrollEdgeAppearance = appearance
} else {
control.barTintColor = barTintColor
}
}
if let shadowImage = style.shadowImage {
if #available(iOS 13.0, *) {
control.standardAppearance.shadowImage = shadowImage
control.scrollEdgeAppearance!.shadowImage = shadowImage
} else {
control.shadowImage = shadowImage
}
}
var attributes = [NSAttributedString.Key: Any]()
if let font = style.font {
attributes[NSAttributedString.Key.font] = font
}
if let fontColor = style.fontColor {
attributes[NSAttributedString.Key.foregroundColor] = fontColor
}
if #available(iOS 13.0, *) {
control.standardAppearance.titleTextAttributes = attributes
control.scrollEdgeAppearance!.titleTextAttributes = attributes
} else {
control.titleTextAttributes = attributes
}
}
}