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];
}
网友评论