//按钮初始化
UIButton * loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
//设置按钮位置
loginButton.frame = CGRectMake(SCREEN_WIDTH * 0.3, SCREEN_HEIGHT * 0.5, 100, 50);
//设置按钮图片
[loginButton setBackgroundImage:[UIImage imageNamed:@"登录"] forState:UIControlStateNormal];
//按钮调用的方法
[loginButton addTarget:self action:@selector(Login:) forControlEvents:UIControlEventTouchUpInside];
//将控件添加到视图上
[self.view addSubview:loginButton];
//调用按钮的方法
-(void)Login:(UIButton *)sender
{
//提示框
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"登录成功" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alert show];
NSLog(@"登录成功");
}