2014-10-31 95 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

相关问题