@@ -80,5 +80,53 @@ public extension UINavigationBar {
8080 }
8181 }
8282 }
83+
84+ @available ( iOS 13 . 0 , * )
85+ func setAppearance( _ value: NavigationBarAppearance ) {
86+ self . standardAppearance = value. standardAppearance
87+ self . scrollEdgeAppearance = value. scrollEdgeAppearance
88+ }
89+
90+ @available ( iOS 13 . 0 , * )
91+ enum NavigationBarAppearance {
92+
93+ case transparentAlways
94+ case transparentStandardOpaqueScroll
95+ case opaqueAlways
96+
97+ var standardAppearance : UINavigationBarAppearance {
98+ switch self {
99+ case . transparentAlways:
100+ let appearance = UINavigationBarAppearance ( )
101+ appearance. configureWithTransparentBackground ( )
102+ return appearance
103+ case . transparentStandardOpaqueScroll:
104+ let appearance = UINavigationBarAppearance ( )
105+ appearance. configureWithTransparentBackground ( )
106+ return appearance
107+ case . opaqueAlways:
108+ let appearance = UINavigationBarAppearance ( )
109+ appearance. configureWithOpaqueBackground ( )
110+ return appearance
111+ }
112+ }
113+
114+ var scrollEdgeAppearance : UINavigationBarAppearance {
115+ switch self {
116+ case . transparentAlways:
117+ let appearance = UINavigationBarAppearance ( )
118+ appearance. configureWithTransparentBackground ( )
119+ return appearance
120+ case . transparentStandardOpaqueScroll:
121+ let appearance = UINavigationBarAppearance ( )
122+ appearance. configureWithTransparentBackground ( )
123+ return appearance
124+ case . opaqueAlways:
125+ let appearance = UINavigationBarAppearance ( )
126+ appearance. configureWithOpaqueBackground ( )
127+ return appearance
128+ }
129+ }
130+ }
83131}
84132#endif
0 commit comments