iOS 用for循环写了一排button
来源:互联网 发布:mac server如何使用 编辑:程序博客网 时间:2024/06/11 03:35
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
float x = 20;
float y = 100;
float w = 30;
float h = 30;
for (int i = 0; i<5; i++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
[btn setFrame:CGRectMake(w*i+x, y, w, h)];
btn.backgroundColor = [UIColor redColor];
[btn setTitle:[NSString stringWithFormat:@"%d",i] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btn_click:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
}
- (void)btn_click:(id)sender
{
UIButton *btn = sender;
btn.backgroundColor = [UIColor greenColor];
}
是这个意思么。点了变颜色了。
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
float x = 20;
float y = 100;
float w = 30;
float h = 30;
for (int i = 0; i<5; i++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
[btn setFrame:CGRectMake(w*i+x, y, w, h)];
btn.backgroundColor = [UIColor redColor];
[btn setTitle:[NSString stringWithFormat:@"%d",i] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btn_click:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
}
- (void)btn_click:(id)sender
{
UIButton *btn = sender;
btn.backgroundColor = [UIColor greenColor];
}
是这个意思么。点了变颜色了。
0 0
- iOS 用for循环写了一排button
- iOS for循环写button
- IOS开发for循环创建button
- ios使用for循环根据个数居中创建一排按钮的代码实现
- 终于学会了用for 循环 写九九乘法口诀
- for循环创建button
- 用for循环写小九九
- 用for循环写九九乘法表
- iOS for循环创建button,button的宽度根据上面的文字来自适应.
- iOS for循环创建button,button的宽度根据上面的文字来自适应.
- for 循环创建button 算法
- 重温for循环创建button
- 用嵌套for循环写九九乘法表
- PHP用for循环写九九乘法表
- iOS自适应button循环创建
- for循环写万年历
- for循环、随机数、函数生成一排自定义石头房-地毯随机色
- ios 代码写Button小结
- MFC中ActiveX控件的使用
- 关于iOS9之后 获取用户是否安装sim卡 的方法
- android jaudiotagger读取mp3和Flac音频操作
- HP pavilion 安装ubuntu14.04后无线无法使用问题总结
- OkHttp的使用
- iOS 用for循环写了一排button
- HDU 2088 Calculate S(n)
- bzoj4390【Usaco2015 Dec】Max Flow
- 二分+贪心 Codeforces614D Skills
- 12306为什么买票这么难
- C语言之括号匹配
- Xcode 快捷键大全
- ListView 数据错乱问题的解决(CheckBox)
- UML类图几种关系的总结