appearanceForTraitCollection: returns nil

Viewed 125

Considering the following lines:

UITraitCollection *traitCollection = [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassCompact];
UITabBarItem *compactAppearance = [UITabBarItem appearanceForTraitCollection:traitCollection];
UITabBarItem *standardAppearance = UITabBarItem.appearance;

compactAppearance is always nil, while standard appearance is working fine.

Debug Info

I have tried with different trait configuration without any success. Is there anything I am missing here.

I have tried with UIButton and it seems to be working. Is this just unsupported for the UITabBarItem? Then how would I cleanly defined different fonts for Compact vs Regular TabBarItems?

0 Answers
Related