42 lines
1.3 KiB
Swift
42 lines
1.3 KiB
Swift
//
|
|
// NavBarModifier.swift
|
|
// PyLeap
|
|
//
|
|
// Created by Trevor Beaton on 3/14/22.
|
|
//
|
|
import SwiftUI
|
|
import Foundation
|
|
|
|
struct NavigationBarModifier: ViewModifier {
|
|
|
|
var backgroundColor: UIColor?
|
|
|
|
init( backgroundColor: UIColor?) {
|
|
self.backgroundColor = backgroundColor
|
|
let coloredAppearance = UINavigationBarAppearance()
|
|
coloredAppearance.configureWithTransparentBackground()
|
|
coloredAppearance.backgroundColor = .clear
|
|
coloredAppearance.titleTextAttributes = [.foregroundColor: UIColor.black]
|
|
coloredAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.black]
|
|
|
|
UINavigationBar.appearance().standardAppearance = coloredAppearance
|
|
UINavigationBar.appearance().compactAppearance = coloredAppearance
|
|
UINavigationBar.appearance().scrollEdgeAppearance = coloredAppearance
|
|
UINavigationBar.appearance().tintColor = .white
|
|
|
|
}
|
|
|
|
func body(content: Content) -> some View {
|
|
ZStack{
|
|
content
|
|
VStack {
|
|
GeometryReader { geometry in
|
|
Color(self.backgroundColor ?? .clear)
|
|
.frame(height: geometry.safeAreaInsets.top)
|
|
.edgesIgnoringSafeArea(.top)
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|