瀏覽代碼

customize tab badge color (#1932)

Bernabé González 7 年之前
父節點
當前提交
2252ac1dde

+ 2
- 1
docs/screen-api.md 查看文件

@@ -219,7 +219,8 @@ Set the badge on a tab (any string or numeric value).
219 219
 ```js
220 220
 this.props.navigator.setTabBadge({
221 221
   tabIndex: 0, // (optional) if missing, the badge will be added to this screen's tab
222
-  badge: 17 // badge value, null to remove badge
222
+  badge: 17, // badge value, null to remove badge
223
+  badgeColor: '#006400', // (optional) if missing, the badge will use the default color
223 224
 });
224 225
 ```
225 226
 ## setTabButton(params = {})

+ 3
- 0
ios/RCCTabBarController.m 查看文件

@@ -263,6 +263,9 @@
263 263
       }
264 264
       else
265 265
       {
266
+        NSString *badgeColor = actionParams[@"badgeColor"];
267
+        UIColor *color = badgeColor != (id)[NSNull null] ? [RCTConvert UIColor:badgeColor] : nil;
268
+        viewController.tabBarItem.badgeColor = color;
266 269
         viewController.tabBarItem.badgeValue = [NSString stringWithFormat:@"%@", badge];
267 270
       }
268 271
     }

+ 1
- 0
src/deprecated/controllers/index.js 查看文件

@@ -244,6 +244,7 @@ var Controllers = {
244 244
         return RCCManager.TabBarControllerIOS(id, "setTabBarHidden", params);
245 245
       },
246 246
       setBadge: function (params) {
247
+        _processProperties(params);
247 248
         return RCCManager.TabBarControllerIOS(id, "setBadge", params);
248 249
       },
249 250
       switchTo: function (params) {

+ 2
- 1
src/deprecated/platformSpecificDeprecated.ios.js 查看文件

@@ -384,7 +384,8 @@ function navigatorSetTabBadge(navigator, params) {
384 384
   if (params.tabIndex || params.tabIndex === 0) {
385 385
     Controllers.TabBarControllerIOS(controllerID + '_tabs').setBadge({
386 386
       tabIndex: params.tabIndex,
387
-      badge: params.badge
387
+      badge: params.badge,
388
+      badgeColor: params.badgeColor
388 389
     });
389 390
   } else {
390 391
     Controllers.TabBarControllerIOS(controllerID + '_tabs').setBadge({