iOS原生弹窗UIAlertController

越努力,越幸运

2019-05-10

原生弹窗

iOS中可用UIAlertController快捷创建上面场景中的弹窗:

- (void)clickAction {

    UIAlertController * alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction *sexMan = [UIAlertAction actionWithTitle:@"男" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        self.cell.sexLabel.text = @"男";
        NSLog(@"选择性别 - 男");
    }];
    UIAlertAction *sexWoman = [UIAlertAction actionWithTitle:@"女" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        self.cell.sexLabel.text = @"女";
        NSLog(@"选择性别 - 女");
    }];
   
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [alertController addAction:sexMan];
    [alertController addAction:sexWoman];
    [alertController addAction:cancelAction];
    [self presentViewController:alertController animated:YES completion:nil];
}

本文发布

简书
LSRain

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。