I'm customizing a UITabBar
in a UITabBarController
subclass ("CustomTabBarVC"). I wanted to use a custom selection indicator image, so I wrote this in the "CustomTabBarVC" implementation:
- (void)viewWillLayoutSubviews
{
CGFloat tabItemWidth;
UIView *tabItem = [[[self.tabBar items] lastObject] view];
tabItemWidth = tabItem.frame.size.width;
UIImage *selectionIndicator;
// Set here 'selectionIndicator' to an UIImage which fits 'tabItemWidth' and tab bar's height
[[UITabBar appearance] setSelectionIndicatorImage:selectionIndicator];
}
This works fine when the view is loaded in portrait, but when I change the orientation of the device to landscape, though the method is called again and selectionIndicator
image seems to take the new width, it is no redrawn and the previous image keeps showing. How could I handle this?
Thanks