Current, I am showing action sheet style UIAlertController
via the following code
@IBAction func attachmentButtonClicked(_ sender: Any) {
let chooseImageImage = UIImage(systemName: "photo")
let takePhotoImage = UIImage(systemName: "camera")
let drawingImage = UIImage(systemName: "paintbrush.pointed")
let recordingImage = UIImage(systemName: "mic")
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let chooseImageAction = UIAlertAction(title: "choose_image".localized, style: .default) {
UIAlertAction in
// Write your code here
}
chooseImageAction.setValue(chooseImageImage, forKey: "image")
let takePhotoAction = UIAlertAction(title: "take_photo".localized, style: .default) {
UIAlertAction in
// Write your code here
}
takePhotoAction.setValue(takePhotoImage, forKey: "image")
let drawingAction = UIAlertAction(title: "drawing".localized, style: .default) {
UIAlertAction in
// Write your code here
}
drawingAction.setValue(drawingImage, forKey: "image")
let recordingAction = UIAlertAction(title: "recording".localized, style: .default) {
UIAlertAction in
// Write your code here
}
recordingAction.setValue(recordingImage, forKey: "image")
let cancelAction = UIAlertAction(title: "Cancel".systemLocalized, style: .cancel) {
UIAlertAction in
// It will dismiss action sheet
}
alert.addAction(chooseImageAction)
alert.addAction(takePhotoAction)
alert.addAction(drawingAction)
alert.addAction(recordingAction)
alert.addAction(cancelAction)
// https://stackoverflow.com/questions/55653187/swift-default-alertviewcontroller-breaking-constraints
self.present(alert, animated: true, completion: nil)
}
The outcome is as following
I was wondering, is there a way to adjust the Y-position of UIAlertController
, so that it will not block the bottom toolbar visibility? I wish the achieve the effect as shown in the following screenshot.