如何在UIAlertController中隐藏标题/消息框?

当使用UIAlertController ,如果我想提供一个空标题和一个空信息的UIActionSheet ,标题和/或消息的预期位置的框架将保留。

我如何改变这个,所以我只提出一个ActionSheet ,内容如下:

设置
登出
取消?

谢谢!

UIAlertController示例

当我用这个代码创build一个UIAlertController时,我没有标题间距。

 [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; 

你是否通过标题和消息或空string?

如果你想在运行时间根据特定的情况改变只写:

actionController.title = nil
actionController.message = nil

UIAlertController * controller = [UIAlertController alertControllerWithTitle:@“”message:@“”preferredStyle:UIAlertControllerStyleAlert]; // style check

 UIAlertAction *first = [UIAlertAction actionWithTitle: @"Login with Facebook" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) { //write to perform action }]; [controller addAction: first]; UIAlertAction *second = [UIAlertAction actionWithTitle: @"Guest User" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) 

{//写入执行操作

 }]; [controller addAction:second]; UIAlertAction *third=[UIAlertAction actionWithTitle:@"Registered User" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { //write to perform action }]; [controller addAction:third]; [self presentViewController: controller animated: YES completion: nil]; 

在swift 2.2中,您可以使用下面的代码,并且我也更改了注销操作button的颜色

  let actionSheet: UIAlertController = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet) self.presentViewController(actionSheet, animated: true, completion: nil) let settingsActionButton: UIAlertAction = UIAlertAction(title: "Settings", style: .Cancel) { action -> Void in print("Settings Tapped") } reportActionSheet.addAction(settingsActionButton) let signOutActionButton: UIAlertAction = UIAlertAction(title: "Signout", style: .Default) { action -> Void in //Clear All Method print("Signout Tapped") } signOutActionButton.setValue(UIColor.redColor(), forKey: "titleTextColor") actionSheet.addAction(signOutActionButton) let cancelActionButton: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in print("Cancel Tapped") } reportActionSheet.addAction(cancelActionButton)