When I create a UIAlertController with this code I don't have the title spacing.
[UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
Are you passing in nil for the title and message or empty strings?
Update Swift 4:
let alert = UIAlertController(title: nil, message: nil, preferredStyle: UIAlertControllerStyle.actionSheet)
Just need to pass nil
to title
and message
params.
If you want to change in run time depending on a certain case just write:
actionController.title = nil
actionController.message = nil
In swift 2.2, you can use code below and I have also changed the color of signout action 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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With