标签展示控件

用UICollectionView封装的标签展示控件 自定义标签风格

    _tagsView = [[TagsView alloc] initWithFrame:CGRectMake(0, 100, [UIScreen mainScreen].bounds.size.width, 10)];
    _tagsView.contentInsets = UIEdgeInsetsMake(0, 20, 0, 20);
    _tagsView.tagInsets = UIEdgeInsetsMake(5, 15, 5, 15);
    _tagsView.lineSpace = 17;
    _tagsView.interitemSpace = 15;
    
    _tagsView.tagLabel.font = [UIFont systemFontOfSize:14];
    _tagsView.tagSelectedLabel.font = [UIFont systemFontOfSize:14];;
    _tagsView.tagLabel.textColor = [UIColor blackColor];
    _tagsView.tagSelectedLabel.textColor = [UIColor redColor];
    _tagsView.tagLabel.backgroundColor = [UIColor whiteColor];
    _tagsView.tagSelectedLabel.backgroundColor = [UIColor yellowColor];
    _tagsView.tagLabel.layer.borderColor = [UIColor lightGrayColor].CGColor;
    _tagsView.tagSelectedLabel.layer.borderColor = [UIColor lightGrayColor].CGColor;
    
    _tagsView.tagLabel.layer.borderWidth = 1;
    _tagsView.tagLabel.layer.cornerRadius = 2;

    _tagsView.delegate = self;
    _tagsView.defaultSelectionFirst = YES;
    //数据
    _dataArray = @[@"我的",@"demo",@"测试项目",@"通过吧sczscddvdvdfd",@"小米",@"iPhone6 Plus",@"咖啡机",@"华为荣耀",@"1111111",@"2222222222",@"3333333333",@"4444444444",@"55555555555555",@"666666666666666"];
    
    _tagsView.tagsArray = _dataArray;
    
    [self.view addSubview:_tagsView];
    
    _tagsView.tagsViewHeightBlock = ^(CGFloat tagsViewHeigh){
        //需要的时候 可以获取到tagsView区域的高度 tagsViewHeigh
    };


//点击标签
#pragma mark TagsViewDelegate
- (void)tagsView:(TagsView *)tagsView didSelectTagAtIndex:(NSUInteger)index {
    NSString *selectedKey = self.dataArray[index];
    NSLog(@"%@",selectedKey);

}

 demo下载地址 https://github.com/jennydan/TagsView.git

转载于:https://www.cnblogs.com/leedandan/p/6812952.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值