您可以将带有 a 的子视图添加UITableView
到UIAlertController
.
1创建 UIAlertController。
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
2创建子视图UITableView
UIVisualEffect *blurEffect;
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *detailsView;
//Let's match the cornerRadius the iOS Style
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) {
detailsView = [[UIVisualEffectView alloc] initWithFrame:CGRectMake(0, -120, alertController.view.frame.size.width-20, 110)];
detailsView.layer.cornerRadius = 15;
} else {
detailsView = [[UIVisualEffectView alloc] initWithFrame:CGRectMake(0, -120, alertController.view.frame.size.width-16, 110)];
detailsView.layer.cornerRadius = 5;
}
detailsView.effect = blurEffect;
detailsView.layer.masksToBounds = YES;
detailsView.alpha = 1;
detailsView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.74];
//Add the UITableView
UITableView *menuTableView = [[UITableView alloc]initWithFrame:detailsView.frame style:UITableViewStylePlain];
[detailsView addSubview:menuTableView];
3添加动作和子视图并呈现UIAlertController
UIAlertAction* resetAction = [UIAlertAction actionWithTitle:@"Reset to default"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action){
//Reset the switches in your UITableViewCells
}];
UIAlertAction* saveAction = [UIAlertAction actionWithTitle:@"Save"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action){
//Save
}];
[alertController addAction:resetAction];
[alertController addAction:saveAction];
// Add the Subview with the UITableView
[alertController.view addSubview:detailsView];
[self presentViewController:alertController animated:YES completion:nil];