@@ -7,6 +7,11 @@ @implementation BottomTabsAppearancePresenter
77#pragma mark - public
88
99- (void )applyBackgroundColor : (UIColor *)backgroundColor translucent : (BOOL )translucent {
10+ if (@available (iOS 26.0 , *)) {
11+ [self setTabBarTransparentBackground ];
12+ self.tabBar .backgroundColor = UIColor.clearColor ;
13+ return ;
14+ }
1015 if (translucent)
1116 [self setTabBarTranslucent: YES ];
1217 else if (backgroundColor.isTransparent )
@@ -19,26 +24,33 @@ - (void)applyBackgroundColor:(UIColor *)backgroundColor translucent:(BOOL)transl
1924
2025- (void )applyTabBarBorder : (RNNBottomTabsOptions *)options {
2126 if (options.borderColor .hasValue || options.borderWidth .hasValue ) {
22- for (UIViewController *childViewController in self.tabBarController .childViewControllers )
23- childViewController.tabBarItem .standardAppearance .shadowImage = [UIImage
24- imageWithSize: CGSizeMake (1.0 , [[options.borderWidth withDefault: @(0.1 )] floatValue ])
25- color: [options.borderColor withDefault: UIColor.blackColor]];
27+ UIImage *borderImage = [UIImage
28+ imageWithSize: CGSizeMake (1.0 , [[options.borderWidth withDefault: @(0.1 )] floatValue ])
29+ color: [options.borderColor withDefault: UIColor.blackColor]];
30+
31+ for (UIViewController *childViewController in self.tabBarController .childViewControllers ) {
32+ childViewController.tabBarItem .standardAppearance .shadowImage = borderImage;
33+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
34+ if (@available (iOS 15.0 , *)) {
35+ childViewController.tabBarItem .scrollEdgeAppearance .shadowImage = borderImage;
36+ }
37+ #endif
38+ }
2639 }
2740}
2841
2942- (void )setTabBarBackgroundColor : (UIColor *)backgroundColor {
30- [self setTabBarOpaqueBackground ];
31- for (UIViewController *childViewController in self.tabBarController .childViewControllers ) {
32- childViewController.tabBarItem .standardAppearance .backgroundColor = backgroundColor;
33- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
34- if (@available (iOS 15.0 , *)) {
35- childViewController.tabBarItem .scrollEdgeAppearance .backgroundColor = backgroundColor;
36- }
37- #endif
43+ UITabBarAppearance *appearance = [self appearanceWithColor: backgroundColor];
44+ [self applyTabBarAppearance: appearance];
45+ self.tabBar .barTintColor = backgroundColor;
46+ self.tabBar .translucent = NO ;
47+ if (@available (iOS 26.0 , *)) {
48+ self.tabBar .backgroundColor = backgroundColor;
3849 }
3950}
4051
4152- (void )setTabBarTranslucent : (BOOL )translucent {
53+ self.tabBar .translucent = translucent;
4254 if (translucent)
4355 [self setTabBarTranslucentBackground ];
4456 else
@@ -48,38 +60,63 @@ - (void)setTabBarTranslucent:(BOOL)translucent {
4860#pragma mark - private
4961
5062- (void )setTabBarDefaultBackground {
51- [self setTabBarOpaqueBackground ];
63+ if (@available (iOS 26.0 , *)) {
64+ [self setTabBarTransparentBackground ];
65+ self.tabBar .backgroundColor = UIColor.clearColor ;
66+ } else {
67+ [self setTabBarOpaqueBackground ];
68+ }
5269}
5370
5471- (void )setTabBarTranslucentBackground {
55- for (UIViewController *childViewController in self.tabBarController .childViewControllers ) {
56- [childViewController.tabBarItem.standardAppearance configureWithDefaultBackground ];
57- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
58- if (@available (iOS 15.0 , *)) {
59- [childViewController.tabBarItem.scrollEdgeAppearance configureWithDefaultBackground ];
60- }
61- #endif
62- }
72+ UITabBarAppearance *appearance = [UITabBarAppearance new ];
73+ [appearance configureWithDefaultBackground ];
74+ [self applyTabBarAppearance: appearance];
75+ self.tabBar .barTintColor = nil ;
6376}
6477
6578- (void )setTabBarTransparentBackground {
66- for (UIViewController *childViewController in self.tabBarController .childViewControllers ) {
67- [childViewController.tabBarItem.standardAppearance configureWithTransparentBackground ];
68- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
69- if (@available (iOS 15.0 , *)) {
70- [childViewController.tabBarItem
71- .scrollEdgeAppearance configureWithTransparentBackground ];
72- }
73- #endif
74- }
79+ UITabBarAppearance *appearance = [UITabBarAppearance new ];
80+ [appearance configureWithTransparentBackground ];
81+ appearance.backgroundEffect = nil ;
82+ appearance.backgroundColor = UIColor.clearColor ;
83+ [self applyTabBarAppearance: appearance];
84+ self.tabBar .barTintColor = UIColor.clearColor ;
7585}
7686
7787- (void )setTabBarOpaqueBackground {
88+ UITabBarAppearance *appearance = [self appearanceWithColor: nil ];
89+ [self applyTabBarAppearance: appearance];
90+ self.tabBar .barTintColor = UIColor.systemBackgroundColor ;
91+ self.tabBar .translucent = NO ;
92+ }
93+
94+ #pragma mark - helpers
95+
96+ - (UITabBarAppearance *)appearanceWithColor : (UIColor *)color {
97+ UITabBarAppearance *appearance = [UITabBarAppearance new ];
98+ [appearance configureWithOpaqueBackground ];
99+ appearance.backgroundEffect = nil ;
100+ appearance.shadowColor = nil ;
101+ UIColor *resolvedColor = color ?: UIColor.systemBackgroundColor ;
102+ appearance.backgroundColor = resolvedColor;
103+ appearance.backgroundImage = [UIImage imageWithSize: CGSizeMake (1 , 1 ) color: resolvedColor];
104+ return appearance;
105+ }
106+
107+ - (void )applyTabBarAppearance : (UITabBarAppearance *)appearance {
108+ self.tabBar .standardAppearance = appearance;
109+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
110+ if (@available (iOS 15.0 , *)) {
111+ self.tabBar .scrollEdgeAppearance = [appearance copy ];
112+ }
113+ #endif
114+
78115 for (UIViewController *childViewController in self.tabBarController .childViewControllers ) {
79- [ childViewController.tabBarItem.standardAppearance configureWithOpaqueBackground ];
116+ childViewController.tabBarItem .standardAppearance = [appearance copy ];
80117#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
81118 if (@available (iOS 15.0 , *)) {
82- [ childViewController.tabBarItem.scrollEdgeAppearance configureWithOpaqueBackground ];
119+ childViewController.tabBarItem .scrollEdgeAppearance = [appearance copy ];
83120 }
84121#endif
85122 }
0 commit comments