Im displaying a badge using CustomBadge with this code:
-(void)viewWillAppear:(BOOL)animated{
[self fillBadges];
//********** Start Custom Badge ***************//
NSString *myNewString = [NSString stringWithFormat:@"%i",allBadge];
if (allBadge >= 1) {
NSLog(@"Add One");
CustomBadge *customBadgeAll = [CustomBadge customBadgeWithString:myNewString];
[customBadgeAll setFrame:CGRectMake(125, 90, customBadgeAll.frame.size.width, customBadgeAll.frame.size.height)];
[self.view addSubview:customBadgeAll];
}
//********** End Custom Badge ***************//
[self.view setNeedsDisplay];
[[self navigationController] setNavigationBarHidden:NO animated:NO];
}
When allBadge count is less than 1, I don’t want the badge to show. How do I remove or hide it from the view.
Thanks
Create a class-wide variable for your customBadgeAll:
in your .h:
then you can easily remove the badge again:
Another way would be to set a the tag value of
customBadgeAllto a special value and later retrieving it using[self.view viewWithTag:...].Hope this helps