自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iOS技巧之Notification,BadgeView

移動開發(fā) iOS
OS可方便的在應(yīng)用圖標(biāo)上添加badgeView,有時候在應(yīng)用程序內(nèi),我們也需要添加像圖標(biāo)上的公色數(shù)字的提醒,本文主要內(nèi)容:1、iOS提醒三種方式,自帶的圖標(biāo)上的badge,alert,notification;2、自定義badgeView

Tips:自定義badgeView需要此類庫,不能使用ARC---badgeView封裝類庫下載 115網(wǎng)盤禮包碼:5lb7f4o6

自定義效果

一、iOS提醒三種方式,自帶的圖標(biāo)上的badge,alert,notification

在需要添加通知處,添加

  1. UILocalNotification *notification=[[UILocalNotification alloc]init]; 
  2.     notification.repeatInterval=0;//設(shè)置提醒重復(fù)的次數(shù) 
  3.     notification.timeZone=[NSTimeZone defaultTimeZone];//設(shè)置時區(qū) 
  4.     //設(shè)置badge 
  5.     notification.applicationIconBadgeNumber=14;//設(shè)置number的值 
  6. notification.soundName=UILocalNotificationDefaultSoundName;//設(shè)置通知聲音   
  7.     // 設(shè)置Alert 
  8.     notification.alertAction=@"打開"
  9.     notification.alertBody=@"提醒"
  10.     notification.hasAction=YES; 
  11.      [[UIApplication sharedApplication]scheduleLocalNotification:notification]; 

二、自定義badgeView

1、將下載的JSBadgeView解壓縮后添加到工程中,添加QuartzCore.framework

2、假設(shè)要在頁面中的button上添加一個Badge,在頁面上添加一個button,創(chuàng)建映射

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

在需要添加badge處添加代碼

  1. //此處alignment有九種狀態(tài)可設(shè)置,一般放在右上角 
  2.     JSBadgeView *badgeView  = [[JSBadgeView alloc ] initWithParentView:self.button alignment:JSBadgeViewAlignmentTopRight]; 
  3.     // 設(shè)置badgeView中的text值,不一定是數(shù)字  
  4.     badgeView.badgeText = @"12"
  5.     //還可設(shè)置badgeView的text字體,圓圈的顏色,陰影顏色等,參照J(rèn)SBadgeView.h中的屬性進(jìn)行自定義 
  6.     [self.button addSubview:badgeView]; 
  7.     [self.view sendSubviewToBack:self.button]; 
責(zé)任編輯:閆佳明 來源: oschina
相關(guān)推薦

2015-07-08 09:56:25

Notificatio多線程

2013-03-25 15:06:26

iOS通信模式

2013-04-11 16:08:50

iOS開發(fā)技巧積累

2014-08-04 17:46:15

NavBarTarBar

2013-05-17 10:54:37

iOS開發(fā)iOS SDK調(diào)試技巧

2017-04-10 18:34:16

AndroidNotificatio

2010-08-01 15:16:41

Android

2011-07-01 16:05:22

SEO

2011-07-25 15:56:45

組策略

2011-12-22 10:33:39

PhoneGap APNotificatio

2018-10-16 15:08:20

屏幕圖像對象

2011-07-25 18:07:29

iPhone Push Notificati

2014-06-09 14:18:24

2011-07-11 15:26:49

性能優(yōu)化算法

2010-08-10 12:55:42

思科IOS備份恢復(fù)

2009-02-26 09:59:00

IOS軟件思科路由器

2013-01-16 08:56:53

iOS故障排除指南

2018-09-12 21:44:32

Linux命令行操作系統(tǒng)

2009-10-27 16:26:58

2011-07-20 14:31:56

XCode User Scrip 腳本
點贊
收藏

51CTO技術(shù)棧公眾號