您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页滚动的button

滚动的button

来源:伴沃教育

-(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);

}

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务