iOS技巧之Notification,BadgeView

Tips:自定义badgeView需要此类库,不能使用ARC---badgeView封装类库下载 115网盘礼包码:5lb7f4o6

自定义效果

一、iOS提醒三种方式,自带的图标上的badge,alert,notification

在需要添加通知处,添加

01 UILocalNotification *notification=[[UILocalNotification alloc]init];
02  
03 notification.repeatInterval=0;//设置提醒重复的次数
04                
05 notification.timeZone=[NSTimeZone defaultTimeZone];//设置时区
06  
07 //设置badge
08 notification.applicationIconBadgeNumber=14;//设置number的值
09                 notification.soundName=UILocalNotificationDefaultSoundName;//设置通知声音
10  
11 // 设置Alert
12 notification.alertAction=@"打开";
13                  
14 notification.alertBody=@"提醒";
15                  
16 notification.hasAction=YES;
17  
18  
19  [[UIApplication sharedApplication]scheduleLocalNotification:notification];
二、自定义badgeView

1、将下载的JSBadgeView解压缩后添加到工程中,添加QuartzCore.framework

2、假设要在页面中的button上添加一个Badge,在页面上添加一个button,创建映射

1 @property (retain, nonatomic) IBOutlet UIButton *button;

在需要添加badge处添加代码

01 //此处alignment有九种状态可设置,一般放在右上角
02 JSBadgeView *badgeView  = [[JSBadgeView alloc ] initWithParentView:self.button alignment:JSBadgeViewAlignmentTopRight];
03  
04 // 设置badgeView中的text值,不一定是数字 
05 badgeView.badgeText = @"12";
06  
07 //还可设置badgeView的text字体,圆圈的颜色,阴影颜色等,参照JSBadgeView.h中的属性进行自定义
08      
09 [self.button addSubview:badgeView];
10      
11 [self.view sendSubviewToBack:self.button];

iOS技巧之Notification,BadgeView

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值