button

作者: 爬你家窗台 | 来源:发表于2016-11-24 16:01 被阅读3次

//按钮初始化

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(@"登录成功");

}

相关文章

网友评论

      本文标题:button

      本文链接:https://www.haomeiwen.com/subject/ufvmettx.html