您的位置:首页 > 产品设计 > UI/UE

UIAlertController 的简单使用方法

2016-01-08 12:03 495 查看
- (void)viewDidLoad {

[super viewDidLoad];

UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];

btn.frame=CGRectMake(10, 60, 80, 30);

[btn setTitle:@"提示框" forState:UIControlStateNormal];

btn.backgroundColor=[UIColor redColor];

[btn addTarget:self action:@selector(gotoAlertVC) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:btn];

}

-(void)gotoAlertVC{

UIAlertController *alertVC=[UIAlertController alertControllerWithTitle:@"提示信息" message:@"iOSQQ技术交流群436337987" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *sureAction=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

NSLog(@"确定加入");

}];

UIAlertAction *cancelAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

NSLog(@"取消加入");

}];

[alertVC addAction:sureAction];

[alertVC addAction:cancelAction];

[self presentViewController:alertVC animated:YES completion:nil];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: