I'm trying to show a badge on some UITabBarItem
s that are configured with an image with UIImageRenderingModeAlwaysOriginal
. I'm doing this because the desired effect is something like a raised UITabBarItem
a-la Instagram. This is the code I'm using to test this (it's in a UITabBarController
category):
- (void) replaceImageForTab:(int)itemIndex
defaultImage:(UIImage *)defaultImage
selectedImage:(UIImage *)selectedImage
title:(NSString *)title
{
NSArray *viewControllers = [self viewControllers];
UIViewController *vc = [viewControllers objectAtIndex:itemIndex];
[vc.tabBarItem setImage:[defaultImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[vc.tabBarItem setSelectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[vc.tabBarItem setTitle:title];
[vc.tabBarItem setBadgeValue:@"1"];
}
However, the badges images are shown clipped, like shown in here:
I think is because the badge is being added within the UITabBar
's UIView
, and it is clipping its contents. But I can't modify that value since that's a private property. What other options do I have here?