//UIButton是iOS中用来响应用户点击的控件,既可以显示文字,也可以显示图片,也可以处理用户交互
//UIButton的创建,一般采用类方法来创建,不需要释放
//UIButton 也是UIControl的子类
//1、创建UIButton(一般用类方法)
//2、配置UIButton
//3、添加到父视图上面
//创建UIButton
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeSystem];
//配置UIButton
// myButton.frame = [CGRectMake(100 , 200 , 50 , 50)];
[myButton setFrame:CGRectMake(100 , 200 , 80 , 60)];
//给UIButton设置要显示的文字
[myButton setTitle:@"login" forState:UIControlStateNormal];
//设置文字大小
myButton.titleLabel.font = [UIFont systemFontOfSize:20];
//给UIButton背景色
// myButton.backgroundColor = [UIColor orangeColor];
//给UIButton添加点击事件
[myButton addTarget:self action:@selector(myButtonAction) forControlEvents:UIControlEventTouchUpInside];
//给button添加图片
[myButton setBackgroundImage:[UIImage imageNamed:@"1.jpg"] forState:UIControlStateNormal];
[myButton setBackgroundImage:[UIImage imageNamed:@"2.jpg"] forState:UIControlStateHighlighted];
//给button添加图片,居中,而不是用al
myButton.contentMode = UIViewContentModeCenter;
//添加到父视图上面
[contentView addSubview:myButton];