美文网首页
滚动的button

滚动的button

作者: Kloar | 来源:发表于2017-03-01 09:14 被阅读12次

-(void)createWeekBtn

{

_weekAry =@[@"周一",@"周二",@"周三",@"周四",@"周五",@"周六",@"周日"];

for (int i =0; i<_weekAry.count; i++) {

UIButton *titleBtn = [UIButton buttonWithType:UIButtonTypeCustom];

[titleBtn setTitle:[_weekAry objectAtIndex:i] forState:UIControlStateNormal];

[titleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

titleBtn.frame = CGRectMake(61*i, 0, 60, 60);

titleBtn.layer.masksToBounds =YES;

titleBtn.layer.cornerRadius =titleBtn.frame.size.width/2;

titleBtn.backgroundColor = [UIColor colorWithRed:0 green:220/255.0 blue:180/255.0 alpha:1.0];

titleBtn.tag = i+1;

[titleBtn addTarget:self action:@selector(clickTitleBtn:) forControlEvents:UIControlEventTouchUpInside];

[_myScrollView addSubview:titleBtn];

}

_myScrollView.contentSize = CGSizeMake(60*_weekAry.count+_weekAry.count, 0);

}

- (void)clickTitleBtn:(id)sender

{

UIButton *buttn = (UIButton *)sender;

NSString *titleStr = [_weekAry objectAtIndex:(buttn.tag - 1)];

NSLog(@"%@",titleStr);

}

相关文章

网友评论

      本文标题:滚动的button

      本文链接:https://www.haomeiwen.com/subject/xvhqgttx.html