uibutton是ios常用控件之一
方法/步骤
1
UIButton* btn=[UIButton buttonWithType:UIButtonTypeCustom]; btn.frame=CGRectMake(100, 50, 100, 40); btn.backgroundColor=[UIColor redColor];[btn setTitle:@'我是按钮' forState:UIControlStateNormal];[self.view addSubview:btn];创建btn并设置颜色为红色
2
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];设置字体颜色为白色
3
[btn setImage:[UIImage imageNamed:@'Acticon-dazao'] forState:UIControlStateNormal];为btn添加图片
4
创建时button有哪些类型,一般选custom
5
[btn setTitle:@'我是按钮' forState:UIControlStateNormal]; btn.titleLabel.text=@'aaaaaaaaaa';用点语法对于button大部分都是不会成功的 都是用set
6
uibutton还有对应的点击事件 [btn addTarget:self action:@selector(btnPress:) forControlEvents:UIControlEventTouchUpInside];还有其他的触发事件
7
大概一般能用到的都在这里了 我觉得 再来一张图吧
上一篇:如何快速打开腾讯在线编辑文档?