BadgeNotification是指呈现在应用程序图标右上角的红色圆形数字提示,用于提示一些无需即时处置的音讯,比方程序更新数、未读邮件数等。BadgeNotification只要在HomeScreen的对应屏上才干看到,因而不合适用于提示一些重要性高或需求及时处置的通知。而且BadgeNotification的外形颜色大小等都是默许且无法改动的。AlertNotification则十分直接地以对话窗口的方式呈现在屏幕上,用于重要或需求及时处置的通知。不过AlertNotification常常粗暴地打断正在停止中的任务,强迫用户马上做出选择,且无法汇总查看一切通知,当有多条通知时,无法选择性处置,只能按提供提供的次第一个个处置。
能够在ios桌面的程序icon右上角显示数字(badgenumber)
[UIApplicationsharedApplication].applicationIconBadgeNumber=3;
//右上角badge number 设置成3
[UIApplicationsharedApplication].applicationIconBadgeNumber=0;
//消掉右上角badgenumber
在UIView上显示Badge(兼容IOS6)Ios6中苹果公司吧badge 的类名改了,改成“_UIBadgeView”了,之前是“UITabBarButtonBadge”,在网上开到这段代码就那过来了。
- -(UIView*)showBadgeValue:(NSString*)strBadgeValue
- {
- UITabBar*tabBar=[[UITabBaralloc]initWithFrame:CGRectMake(0,0,320,50)];
- UITabBarItem*item=[[UITabBarItemalloc]initWithTitle:@""image:niltag:0];
- item.badgeValue=strBadgeValue;
- NSArray*array=[[NSArrayalloc]initWithObjects:item,nil];
- tabBar.items=array;
- [itemrelease];
- [arrayrelease];
- //寻找
- for(UIView*viewTabintabBar.subviews){
- for(UIView*subviewinviewTab.subviews){
- NSString*strClassName=[NSStringstringWithUTF8String:object_getClassName(subview)];
- if([strClassNameisEqualToString:@"UITabBarButtonBadge"]||
- [strClassNameisEqualToString:@"_UIBadgeView"]){
- //从原视图上移除
- [subviewremoveFromSuperview];
- //
- [selfaddSubview:subview];
- subview.frame=CGRectMake(self.frame.size.width-subview.frame.size.width,0,
- subview.frame.size.width,subview.frame.size.height);
- [tabBarrelease];
- returnsubview;
- }
- }
- }
- [tabBarrelease];
- returnnil;
- }
- -(void)removeBadgeValue
- {
- //
- for(UIView*subviewinself.subviews){
- NSString*strClassName=[NSStringstringWithUTF8String:object_getClassName(subview)];
- if([strClassNameisEqualToString:@"UITabBarButtonBadge"]||
- [strClassNameisEqualToString:@"_UIBadgeView"]){
- [subviewremoveFromSuperview];
- break;
- }
- }
- }