首页 >> 大全

iOS技巧之Notification,BadgeView

2023-11-26 大全 32 作者:考证青年

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

自定义效果

iOS技巧之Notification,BadgeView__iOS技巧之Notification,BadgeView

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

在需要添加通知处,添加

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];

二、自定义

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

iOS技巧之Notification,BadgeView__iOS技巧之Notification,BadgeView

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

@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];

关于我们

最火推荐

小编推荐

联系我们


版权声明:本站内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 88@qq.com 举报,一经查实,本站将立刻删除。备案号:桂ICP备2021009421号
Powered By Z-BlogPHP.
复制成功
微信号:
我知道了