IOS标签按钮的选择
typedef enum : NSUInteger { FLSearchLabelButInformation = 1000, //资讯 FLSearchLabelButBBs = 1001, //论坛 FLSearchLabelButMall = 1002, //商城 FLSearchLabelButMobile = 1003, //手机 } FLSearchLabelBut; - (void)creatleUI{ NSArray *dataArry = @[@"咨询", @"论坛", @"商城", @"手机"]; CGFloat deli_with = 50; for (int index = 0; index < dataArry.count; index++) { UIButton *butt = [UIButton buttonWithType:UIButtonTypeCustom]; butt.frame = CGRectMake(deli_with *index, 0, deli_with, CGRectGetHeight(self.frame)); butt.tag = FLSearchLabelButInformation + index; [butt setTitleColor:[UIColor colorWithString:@"#969696"] forState:UIControlStateNormal]; if(index==0){ [butt setTitleColor:[UIColor colorWithString:@"#262626"] forState:UIControlStateNormal]; } [butt setTitle:dataArry[index] forState:UIControlStateNormal]; butt.titleLabel.font = [UIFont systemFontOfSize:14.0f]; [butt addTarget:self action:@selector(onClickView:) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:butt]; } } - (void)onClickView:(UIButton *)sender{ for(UIView *locateView in self.subviews){ if([locateView isKindOfClass:[UIButton class]]){ UIButton *locateButt = (UIButton *)locateView; [locateButt setTitleColor:[UIColor colorWithString:@"#969696"] forState:UIControlStateNormal]; } } [sender setTitleColor:[UIColor colorWithString:@"#262626"] forState:UIControlStateNormal]; if([_delegate respondsToSelector:@selector(onClickSearhbutt:)]){ [_delegate onClickSearhbutt:sender.tag]; } }
创新互联服务项目包括宜君网站建设、宜君网站制作、宜君网页制作以及宜君网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,宜君网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到宜君省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
点击每个标签改变当前的颜色
新闻标题:IOS标签按钮的选择
文章起源:http://scgulin.cn/article/ghgeeh.html