Tips:自定义badgeView需要此类库,不能使用ARC---badgeView封装类库下载 115网盘礼包码:5lb7f4o6
自定义效果
一、iOS提醒三种方式,自带的图标上的badge,alert,notification
在需要添加通知处,添加
01 | UILocalNotification *notification=[[UILocalNotification alloc]init]; |
03 | notification.repeatInterval=0; |
05 | notification.timeZone=[NSTimeZone defaultTimeZone]; |
08 | notification.applicationIconBadgeNumber=14; |
09 | notification.soundName=UILocalNotificationDefaultSoundName; |
12 | notification.alertAction=@ "打开" ; |
14 | notification.alertBody=@ "提醒" ; |
16 | notification.hasAction=YES; |
19 | [[UIApplication sharedApplication]scheduleLocalNotification:notification]; |
二、自定义badgeView
1、将下载的JSBadgeView解压缩后添加到工程中,添加QuartzCore.framework
2、假设要在页面中的button上添加一个Badge,在页面上添加一个button,创建映射
1 | @property (retain, nonatomic) IBOutlet UIButton *button; |
在需要添加badge处添加代码
02 | JSBadgeView *badgeView = [[JSBadgeView alloc ] initWithParentView:self.button alignment:JSBadgeViewAlignmentTopRight]; |
05 | badgeView.badgeText = @ "12" ; |
09 | [self.button addSubview:badgeView]; |
11 | [self.view sendSubviewToBack:self.button]; |
iOS技巧之Notification,BadgeView