Reputation: 750
I need Your help again.I create one view controller in this view controller both navigation bar button have badge with number.I have tried and search every where but I am not getting any solution of this problem and every where they are just provide the solution for tabbar or on custom button.
so now I have need badge on navigation bar button,help me out of this problem.
Thank you.
Upvotes: 2
Views: 4041
Reputation: 6016
Create a custom view containing a button and badge and add that view to the right or left bar button of navigation controller. Thats the only way you can do it, else there is no native way to add badge and button in navigation bar button item.
Edit:
Do Some thing like this,
UIView *BtnView = [[UIView alloc] initWithFrame:CGRectMake(0,0,70,35)];
UIButton *myButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
[myButton setFrame:CGRectMake(0,0,70,35)];
[myButton setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
[BtnView addSubview:myButton];
[myButton release];
UIBarButtonItem* barButton = [[UIBarButtonItem alloc] initWithCustomView:BtnView];
viewController.navigationItem.leftBarButtonItem = barButton;
[BtnView release];
[barButton release];
Upvotes: 3