IOS 为Button添加一个提示数量的角标
2016-08-16 11:21
471 查看
UIView * homeButtonView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 25, 25)];
UIImageView * homeButtonImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 25, 25)];
homeButtonImageView.image = [UIImage imageNamed:@"icon_12"];
UIButton * homeButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 25, 25)];
homeButton.backgroundColor = [UIColor clearColor];
[homeButton addTarget:self action:@selector(tapRightItem) forControlEvents:UIControlEventTouchUpInside];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 10, 10)];
label.text = @"2";
label.textColor = [UIColor whiteColor];
label.backgroundColor=[UIColor redColor];
label.textAlignment = NSTextAlignmentCenter;
label.layer.cornerRadius=5;
label.layer.masksToBounds =YES;
label.font = [UIFont systemFontOfSize:KSCREEN_HEIGHT(11)];
[homeButton addSubview:label];]
[homeButtonView addSubview:homeButtonImageView];
[homeButtonView addSubview:homeButton];
UIBarButtonItem *homeButtonItem = [[UIBarButtonItem alloc]initWithCustomView:homeButtonView];
self.navigationItem.rightBarButtonItem=homeButtonItem;
UIImageView * homeButtonImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 25, 25)];
homeButtonImageView.image = [UIImage imageNamed:@"icon_12"];
UIButton * homeButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 25, 25)];
homeButton.backgroundColor = [UIColor clearColor];
[homeButton addTarget:self action:@selector(tapRightItem) forControlEvents:UIControlEventTouchUpInside];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 10, 10)];
label.text = @"2";
label.textColor = [UIColor whiteColor];
label.backgroundColor=[UIColor redColor];
label.textAlignment = NSTextAlignmentCenter;
label.layer.cornerRadius=5;
label.layer.masksToBounds =YES;
label.font = [UIFont systemFontOfSize:KSCREEN_HEIGHT(11)];
[homeButton addSubview:label];]
[homeButtonView addSubview:homeButtonImageView];
[homeButtonView addSubview:homeButton];
UIBarButtonItem *homeButtonItem = [[UIBarButtonItem alloc]initWithCustomView:homeButtonView];
self.navigationItem.rightBarButtonItem=homeButtonItem;
相关文章推荐
- iOS实现类似QQ的好友列表,自由展开折叠(在原来TableView的基础上添加一个字典,一个Button)
- iOS实现自定义购物车角标显示购物数量(添加商品时角标抖动 Vie)
- 点击一个button就能出来word,不过会有安全提示
- asp:ButtonColumn添加删除提示的几种方法
- iOS学习之动态添加Button和监听UIAlertView按钮
- IOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem
- iOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem
- 添加一个右击命令行提示符
- UIScrollView基本使用。为其它添加多个button ||-iOS objective-c
- IOS学习之动态添加Button和监听UIAlertView按钮
- IOS学习之动态添加Button和监听UIAlertView按钮
- IOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem
- 为你的程序添加“QQ提示”(屏幕的右下角弹出一个提示)
- ios UIImagePickerController 添加一个自定义的view。
- button添加一个确定提示框
- IOS学习1 动态添加Button
- b/s软件中使用Access数据库,只能查询,不能添加、修改、删除,提示操作必须是一个可更新的查询解决。
- 使用CSS给ASP.NET中的Button按钮添加一个指定位置的图片
- 一个点击添加button的例子
- IOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem