Seong Lee Seong Lee - 2 years ago 138
Swift Question

How to make Alert action title-less

I want to remove a title section from an Alert action.
Making title string

won't remove the title section

@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
let gallaryAction = UIAlertAction(title: "Choose Photo", style: UIAlertActionStyle.Default)
UIAlertAction in
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel)
UIAlertAction in


// Add the actions

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


This is what I'm getting:

enter image description here

How can I remove the title section all together?

Answer Source

"title" is an optional value, if you pass nil instead of the empty string, it will get rid of the title area.

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download