iOS技巧之Notification,BadgeView
来源:互联网 发布:做完系统电脑优化 编辑:程序博客网 时间:2024/06/07 23:20
OS可方便的在应用图标上添加badgeView,有时候在应用程序内,我们也需要添加像图标上的公色数字的提醒,本文主要内容:1、iOS提醒三种方式,自带的图标上的badge,alert,notification;2、自定义badgeView
AD:2013云计算架构师峰会课程资料下载
Tips:自定义badgeView需要此类库,不能使用ARC---badgeView封装类库下载 115网盘礼包码:5lb7f4o6
自定义效果
一、iOS提醒三种方式,自带的图标上的badge,alert,notification
在需要添加通知处,添加
- UILocalNotification *notification=[[UILocalNotification alloc]init];
- notification.repeatInterval=0;//设置提醒重复的次数
- notification.timeZone=[NSTimeZone defaultTimeZone];//设置时区
- //设置badge
- notification.applicationIconBadgeNumber=14;//设置number的值
- notification.soundName=UILocalNotificationDefaultSoundName;//设置通知声音
- // 设置Alert
- notification.alertAction=@"打开";
- notification.alertBody=@"提醒";
- notification.hasAction=YES;
- [[UIApplication sharedApplication]scheduleLocalNotification:notification];
二、自定义badgeView
1、将下载的JSBadgeView解压缩后添加到工程中,添加QuartzCore.framework
2、假设要在页面中的button上添加一个Badge,在页面上添加一个button,创建映射
- @property (retain, nonatomic) IBOutlet UIButton *button;
在需要添加badge处添加代码
- //此处alignment有九种状态可设置,一般放在右上角
- JSBadgeView *badgeView = [[JSBadgeView alloc ] initWithParentView:self.button alignment:JSBadgeViewAlignmentTopRight];
- // 设置badgeView中的text值,不一定是数字
- badgeView.badgeText = @"12";
- //还可设置badgeView的text字体,圆圈的颜色,阴影颜色等,参照JSBadgeView.h中的属性进行自定义
- [self.button addSubview:badgeView];
- [self.view sendSubviewToBack:self.button];
0 0
- iOS技巧之Notification,BadgeView
- iOS技巧之Notification,BadgeView
- ios之Notification
- ios开发之Notification
- iOS之Notification
- Android技巧小结之新旧版本Notification
- Android技巧小结之新旧版本Notification
- Badgeview
- BadgeView
- BadgeView
- iOS之Local Notification(本土通知)
- iOS学习之——Notification补充
- iOS开发之Notification与多线程
- iOS Notification
- iOS Notification
- ios notification
- iOS--Notification
- ios notification
- svn switch 导致个别文件switch失败
- Win32下的线程和MFC的线程实现
- 等待
- 修心
- MySQL 清除连接(仅备忘)
- iOS技巧之Notification,BadgeView
- js如何遍历本地目录的文件
- Java面向对象——泛型
- 小议腾讯入股京东
- PHP5.3, PHP5.4, PHP5.5新特性
- PAT 1017. Queueing at Bank (25)
- android事件传递机制以及onInterceptTouchEvent()和onTouchEvent()详解二之小秘与领导的故事
- 用Gson解析JSON 的方法
- 树状数组模板