『iOS学习笔记』 UIButton-1
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
/// UIButton //创建UIButton UIButton *tmpButton =[[[UIButton alloc] init]autorelease]; //设置背景颜色 tmpButton.backgroundColor = [UIColor blueColor]; //设置标题文本 [tmpButton setTitle:@"MyButton" forState:UIControlStateNormal]; //设置标题文本的颜色 [tmpButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; //设置图片 UIImage *image3=[UIImage imageNamed:@"a3.png"]; [tmpButton setImage:image3 forState:UIControlStateNormal]; //设置位置和大小 tmpButton.frame = CGRectMake(0, 0, 200, 0);//在这里仅Width有效 //向容器中添加UIButton