Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 UITabBar badge position

Is there any way to adjust the position of the UITabBar badge in iOS 7? The badge now blocks the tab bar icon a bit more than I would like.

iOS 6: enter image description here

iOS 7: enter image description here

like image 655
Keller Avatar asked Oct 03 '13 17:10

Keller


3 Answers

It looks like the badge is placed in a certain position relative to the image. So if you have no image, the badge is in the upper left corner of the tabBarItem.

So - to position the badge, adjust the border of blank pixels around the .png you're using for the tabBarItem image.

like image 126
Andrew Bennett Avatar answered Oct 15 '22 16:10

Andrew Bennett


If possible, can you provide the method by which you are setting the tab bar image?

I had the same problem that you did, and fixed it by using UIImageRenderingModeAlwaysOriginal:

UIImage *image = // Your tab bar item image
UIImage *selected = // Your selected tab bar item image

image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
selected = [selected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

controller.tabBarItem = [[UITabBarItem alloc] initWithTitle:title
                                                      image:image
                                              selectedImage:selected];

Cheers!

like image 1
Daniel Amitay Avatar answered Oct 15 '22 17:10

Daniel Amitay


It's not possible to adjust appearance of the badge.

If you really want to have it different, I think implementing custom overlay on UITabBar should be pretty easy. That way you could put there any custom text, not just numbers.

like image 1
Tricertops Avatar answered Oct 15 '22 17:10

Tricertops