Chinthaka
Chinthaka

Reputation: 988

How to customise the iOS badge number background

How can I customise the badge number on UITabBarItem?

Something like this

enter image description here

Upvotes: 1

Views: 1613

Answers (1)

pmk
pmk

Reputation: 1897

Have a Look at MKNumberBadgeView. Its a little Class for your Custom BadgeView.

Using it like this I am able to add it to my custom UITabBarController:

    MKNumberBadgeView *badge = [[MKNumberBadgeView alloc] initWithFrame:CGRectMake(110, self.view.frame.size.height-20, 30, 30)];
    badge.value = 12;
    UIWindow *window = [[UIApplication sharedApplication].windows objectAtIndex:0];
    [[[window subviews] objectAtIndex:0] addSubview:badge];

Wich will look like this:

enter image description here

Of course you have to take care of rotating issues when adding the badgeView to the window. But I guess you can customize MKNumberBadgeView to make it look the way you want it, give it a try.

Upvotes: 6

Related Questions