美文网首页iOS开发
iOS原生弹窗UIAlertController

iOS原生弹窗UIAlertController

作者: LSRain | 来源:发表于2019-05-10 23:06 被阅读0次

    越努力,越幸运

    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

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