react-native-navigation的迁移库

TabBarItemAppearanceCreator.m 1.4KB

1234567891011121314151617181920212223242526
  1. #import "TabBarItemAppearanceCreator.h"
  2. @implementation TabBarItemAppearanceCreator
  3. + (UITabBarItem *)createTabBarItem:(UITabBarItem *)mergeItem {
  4. UITabBarItem* tabBarItem = [super createTabBarItem:mergeItem];
  5. tabBarItem.standardAppearance = mergeItem.standardAppearance ?: [[UITabBarAppearance alloc] init];
  6. return tabBarItem;
  7. }
  8. + (void)setTitleAttributes:(UITabBarItem *)tabItem titleAttributes:(NSDictionary *)titleAttributes {
  9. [super setTitleAttributes:tabItem titleAttributes:titleAttributes];
  10. tabItem.standardAppearance.stackedLayoutAppearance.normal.titleTextAttributes = titleAttributes;
  11. tabItem.standardAppearance.compactInlineLayoutAppearance.normal.titleTextAttributes = titleAttributes;
  12. tabItem.standardAppearance.inlineLayoutAppearance.normal.titleTextAttributes = titleAttributes;
  13. }
  14. + (void)setSelectedTitleAttributes:(UITabBarItem *)tabItem selectedTitleAttributes:(NSDictionary *)selectedTitleAttributes {
  15. [super setSelectedTitleAttributes:tabItem selectedTitleAttributes:selectedTitleAttributes];
  16. tabItem.standardAppearance.stackedLayoutAppearance.selected.titleTextAttributes = selectedTitleAttributes;
  17. tabItem.standardAppearance.compactInlineLayoutAppearance.selected.titleTextAttributes = selectedTitleAttributes;
  18. tabItem.standardAppearance.inlineLayoutAppearance.selected.titleTextAttributes = selectedTitleAttributes;
  19. }
  20. @end