ios - 如何使警报操作无标题

标签 ios swift uialertcontroller

<分区>

我想从警报操作中删除标题部分。 制作标题字符串 "" 不会删除标题部分

@IBAction func addImage(sender: AnyObject!) {

    let alert:UIAlertController = UIAlertController(title: "" ,message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)

    let cameraAction = UIAlertAction(title: "Take Photo", style: UIAlertActionStyle.Default)
        {
            UIAlertAction in
            self.openCamera()
    }
    let gallaryAction = UIAlertAction(title: "Choose Photo", style: UIAlertActionStyle.Default)
        {
            UIAlertAction in
            self.openGallary()
    }
    let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel)
        {
            UIAlertAction in

    }

    // Add the actions
    alert.addAction(cameraAction)
    alert.addAction(gallaryAction)
    alert.addAction(cancelAction)

    // Present the controller
    self.presentViewController(alert, animated: true, completion: nil)

}

这是我得到的:

enter image description here

如何一起删除标题部分?

最佳答案

"title"是一个可选值,如果你传递 nil 而不是空字符串,它会去掉标题区域。

let alert:UIAlertController = UIAlertController(title: nil ,message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)

关于ios - 如何使警报操作无标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36853213/

相关文章:

ios - 崩溃 - [CTTelephonyNetworkInfo updateRat :descriptor:]

ios - 如何以编程方式将颜色设置为 Cayenne

ios - 以编程方式取消 Mapbox MapView 动画

ios - UIAlertController 在 swift 3 的启动 View 中不工作

ios - 不在 View Controller 中时如何呈现 UIAlertController?

ios - 如何隐藏uiwebview导航按钮

ios - 如何从字符串中解析十进制而不丢失精度?

swift - 在 SwiftUI 中递归构建菜单

ios - 使用通用函数

ios - dismissViewControllerAnimated 在 block 内不起作用