您的位置:首页 > 其它

Button添加红色的数字圆圈

2016-01-15 16:28 393 查看
如何给APP上面的Button添加红色的标示,类似如下的效果



其实很简单的,follow me~~~

1、添加一个类库:JSBadgeView

网上自己找了

2、随便定义一个button,然后添加之即可显示,代码如下喽

UIButton *btnMsg = [[UIButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(imageView.frame) + h1 * 0.4, h2 + 64 + h1 * 0.25, h1 * 0.25, h1 * 0.25)];
forState:UIControlStateNormal];
[btnMsg setImage:[UIImage imageNamed:@"xiaoxi"] forState:UIControlStateNormal];
[btnMsg setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
//this point====
js1 = [[JSBadgeView alloc]initWithParentView:btnMsg alignment:JSBadgeViewAlignmentTopRight];
[btnMsg addSubview:js1];
js1.badgeText = [NSString stringWithFormat:@"10"];
[self.view addSubview:btnMsg];


就像上面一样简单,然后你的功能就可以实现了,很简单吧,多用用就熟悉了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: