首页 > 其他 > 详细

红色小圆点+数字的badge自定义小方法 by Nicky.Tsui

时间:2015-06-08 09:31:49      阅读:201      评论:0      收藏:0      [点我收藏+]

技术分享

效果如图.

实现方法比较简单,在view上增加一个label label设置:

 1             badgeLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(imageView.frame)+2, -10, 20, 20)];
 2             badgeLabel.text = @"0";
 3             badgeLabel.textColor = [UIColor whiteColor];      //文字颜色
 4             badgeLabel.textAlignment = NSTextAlignmentCenter;     //居中
 5             badgeLabel.layer.borderColor = [UIColor whiteColor].CGColor;    边界白色
 6             badgeLabel.layer.borderWidth = 1.5;     //边界宽度
 7             badgeLabel.layer.cornerRadius = 10;     //这个为frame size 的一半,既变成圆形
 8             badgeLabel.layer.masksToBounds = YES;   
 9             badgeLabel.layer.backgroundColor = [UIColor redColor].CGColor;  //红色背景
10             badgeLabel.font = [UIFont boldSystemFontOfSize:12];  

 

红色小圆点+数字的badge自定义小方法 by Nicky.Tsui

原文:http://www.cnblogs.com/sixindev/p/4560103.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!