//标签类
- (void)addTagLabel
{
_titleArr = [NSMutableArray arrayWithObjects:@"现房", @"股权交易", @"150年",nil];
//拿到屏幕的宽
CGFloat kScreenW = [UIScreen mainScreen].bounds.size.width;
//间距
CGFloatpadding =10;
CGFloattitBtnX =12;
CGFloattitBtnY =49;
CGFloattitBtnH =30;
for(inti =0; i <_titleArr.count; i++){
UIButton *titBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//设置按钮的样式
titBtn.backgroundColor=RGB(255,103,103,0.1);
[titBtnsetTitleColor:RGB(255, 103, 103, 1) forState:UIControlStateNormal];
titBtn.titleLabel.font= [UIFontsystemFontOfSize:12];
[titBtnsetTitle:_titleArr[i] forState:UIControlStateNormal];
titBtn.tag=1000+i;
[titBtnaddTarget:self action:@selector(titBtnClike:) forControlEvents:UIControlEventTouchUpInside];
//计算文字大小
CGSize titleSize = [_titleArr[i] boundingRectWithSize:CGSizeMake(MAXFLOAT, titBtnH) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:titBtn.titleLabel.font} context:nil].size;
CGFloattitBtnW = titleSize.width+2* padding;
//设置按钮的位置
titBtn.frame=CGRectMake(titBtnX, titBtnY, titBtnW, titBtnH);
titBtnX += titBtnW + padding;
[selfaddSubview:titBtn];
}
}
//点击事件
- (void)handleClick:(UIButton*)btn{
}