如何给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];
就像上面一样简单,然后你的功能就可以实现了,很简单吧,多用用就熟悉了。