2014-10-31 91 views
2

我正在製作收件箱模塊,我想在標籤上顯示消息數。數據來自服務器。所以如果我們有30條消息,標籤將顯示30條消息。如何做到這一點?做推送通知的概念會用在這裏還是別的什麼東西?如何在ios中的收件箱中顯示消息數

+0

r你在應用程序內部使用這種方法 – 2014-10-31 05:13:21

+0

意味着?應用程序內的方法? – 2014-10-31 05:16:33

回答

0

創建通過編程方式或使用IBOutlet的一個UILablel並設置frame其中u要申請,最後定像

#import <QuartzCore/QuartzCore.h> 


UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(50, 50, 30, 30)]; //change the frame size as you need 
label.layer.borderColor = [UIColor whiteColor].CGColor; 
label.layer.borderWidth = 2.0; 
label.layer.cornerRadius = label.bounds.size.height/2; 
label.TextAlignment=NSTextAlignmentCenter; 
label.layer.masksToBounds = YES; 
label.text=[NSString stringWithFormat:@"%d",yourarrayname.count]; // here add your message array name 
label.textColor=[UIColor whiteColor]; 
label.backgroundColor=[UIColor redColor]; 
[self.view addSubview:label]; 

斯威夫特

let label: UILabel = UILabel(frame: CGRectMake(50, 50, 30, 30))//change the frame size as you need 
label.layer.borderColor = UIColor.whiteColor().CGColor 
label.layer.borderWidth = 2.0 
label.layer.cornerRadius = label.bounds.size.height/2 
label.TextAlignment = .Center 
label.layer.masksToBounds = true 
label.text = "\(yourarrayname.count)" // here add your message array name 
label.textColor = UIColor.whiteColor() 
label.backgroundColor = UIColor.redColor() 
self.view!.addSubview(label) 

輸出

enter image description here

+0

如果你需要任何幫助,我改變了我的答案 – 2014-10-31 05:40:45

+0

會讓你知道後檢查它.. :)符合我的標準:) – 2014-10-31 12:59:51

相關問題