#define ImageButtonWidth kScreenW / 5#define widgtWidth ImageButtonWidth * 6- (UIScrollView *)categoryView { if (!_categoryView) { _categoryView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,self.bannerHeight + Scale(10), kScreenW, Scale(86.0f))]; _categoryView.backgroundColor = [UIColor whiteColor]; _categoryView.contentSize = CGSizeMake(widgtWidth, 86); _categoryView.showsHorizontalScrollIndicator = NO; CGFloat itemW = (kScreenW-2*Scale(15))/5.0; NSArray *titles = @[@"医声直播",@"学术专栏",@"经典病例",@"每日一题",@"学科分类",@"医生工具"]; NSArray *imgs = @[@"home_cate_live",@"home_cate_subject",@"home_cate_case",@"home_cate_score",@"home_cate_cate",@"home_cate_cate"]; for (int i=0; i<titles.count; i++) { UIButton *btn = [[UIButton alloc]init]; CGFloat btnX = itemW * i + Scale(15); CGFloat btnY = 10; btn.frame = CGRectMake(btnX,btnY, itemW, itemW); btn.tag = 1000 + i; btn.titleLabel.font = LYFont(Scale(13)); [btn setImage:ImageNamed(imgs[i]) forState:UIControlStateNormal]; [btn setTitle:titles[i] forState:UIControlStateNormal]; [btn setTitleColor:LYHexColor(@"#545454") forState:UIControlStateNormal]; [btn addTarget:self action:@selector(functionBtnClick:) forControlEvents:UIControlEventTouchUpInside]; [_categoryView addSubview:btn]; [btn layoutButtonWithEdgeInsetsStyle:JTButtonEdgeInsetsStyleTop imageTitleSpace:5]; } } return _categoryView;}
网友评论