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

你可能感兴趣的:(iOS原生弹窗UIAlertController)