Skip to content

Instantly share code, notes, and snippets.

@GingerBear
Last active June 23, 2017 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GingerBear/d95fe862a506a2db605ad6026a18bf1c to your computer and use it in GitHub Desktop.
Save GingerBear/d95fe862a506a2db605ad6026a18bf1c to your computer and use it in GitHub Desktop.
add text position adjust to tabbar label RCCTabBarController.m
    id imageInsets = tabItemLayout[@"props"][@"iconInsets"];
    if (imageInsets && imageInsets != (id)[NSNull null])
    {
      id topInset = imageInsets[@"top"];
      id leftInset = imageInsets[@"left"];
      id bottomInset = imageInsets[@"bottom"];
      id rightInset = imageInsets[@"right"];
      
      CGFloat top = topInset != (id)[NSNull null] ? [RCTConvert CGFloat:topInset] : 0;
      CGFloat left = topInset != (id)[NSNull null] ? [RCTConvert CGFloat:leftInset] : 0;
      CGFloat bottom = topInset != (id)[NSNull null] ? [RCTConvert CGFloat:bottomInset] : 0;
      CGFloat right = topInset != (id)[NSNull null] ? [RCTConvert CGFloat:rightInset] : 0;
      
      viewController.tabBarItem.imageInsets = UIEdgeInsetsMake(top, left, bottom, right);
+      viewController.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -2);
    }
    NSMutableDictionary *unselectedAttributes = [RCTHelpers textAttributesFromDictionary:tabsStyle withPrefix:@"tabBarText" baseFont:[UIFont systemFontOfSize:10]];
    if (!unselectedAttributes[NSForegroundColorAttributeName] && labelColor) {
      unselectedAttributes[NSForegroundColorAttributeName] = labelColor;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment