@@ -69,6 +69,10 @@ open class WaveTabBarController: UITabBarController, WaveTabBarProtocol {
6969 }
7070 }
7171
72+ open override func viewWillLayoutSubviews( ) {
73+ presenter. viewWillLayoutSubviews ( )
74+ }
75+
7276 // MARK: - WaveTabBarProtocol functions
7377
7478 func showTabBar( _ show: Bool , animated: Bool , over duration: TimeInterval ) {
@@ -110,23 +114,34 @@ open class WaveTabBarController: UITabBarController, WaveTabBarProtocol {
110114 circle. layer. cornerRadius = CGFloat ( radius) / 2
111115 }
112116
113- func setupTabBarStyling ( ) {
117+ func setupTabBarColoring ( ) {
114118 let backgroundColor : UIColor
115- if let color = tabBar. barTintColor {
116- backgroundColor = color
117- } else {
118- switch tabBar. barStyle {
119- case . black, . blackTranslucent: backgroundColor = Constants . blackBackgroundColor
120- case . default: backgroundColor = Constants . whiteBackgroundColor
121- @unknown default : backgroundColor = Constants . whiteBackgroundColor
119+ if #available( iOS 13 . 0 , * ) {
120+ switch traitCollection. userInterfaceStyle {
121+ case . light: backgroundColor = Constants . whiteBackgroundColor
122+ case . dark: backgroundColor = Constants . blackBackgroundColor
123+ case . unspecified: backgroundColor = getColorFromTabBarStyle ( )
124+ @unknown default : backgroundColor = getColorFromTabBarStyle ( )
122125 }
126+ } else {
127+ backgroundColor = getColorFromTabBarStyle ( )
123128 }
124129 waveSubLayer. fillColor = backgroundColor. cgColor
125130 circle? . backgroundColor = backgroundColor
126- tabBar. backgroundColor = . clear
127- tabBar. tintColor = UIColor . clear
128- tabBar. backgroundImage = UIImage ( )
129- tabBar. shadowImage = UIImage ( )
131+ }
132+
133+ func setupTabBarBackground( ) {
134+ tabBar. tintColor = . clear
135+ if #available( iOS 13 . 0 , * ) {
136+ let barAppearance = UIBarAppearance ( )
137+ barAppearance. configureWithTransparentBackground ( )
138+ let tabBarAppearance = UITabBarAppearance ( barAppearance: barAppearance)
139+ tabBar. standardAppearance = tabBarAppearance
140+ } else {
141+ tabBar. backgroundColor = . clear
142+ tabBar. backgroundImage = UIImage ( )
143+ tabBar. shadowImage = UIImage ( )
144+ }
130145 }
131146
132147 func setupImageView( _ center: Float ) {
@@ -192,4 +207,14 @@ open class WaveTabBarController: UITabBarController, WaveTabBarProtocol {
192207 circle. alpha = down ? Constants . emptyAlpha : Constants . fullAlpha
193208 }
194209
210+ // MARK: - Private functions
211+
212+ private func getColorFromTabBarStyle( ) -> UIColor {
213+ switch tabBar. barStyle {
214+ case . black, . blackTranslucent: return Constants . blackBackgroundColor
215+ case . default: return Constants . whiteBackgroundColor
216+ @unknown default : return Constants . whiteBackgroundColor
217+ }
218+ }
219+
195220}
0 commit comments