Display AlertController with ActionSheet in Swift (XCODE 8.3)

October 24, 2017

You can display list of items (Action Sheet ) with the UIAlertController in the iOS application

In the following example I have created Alert Controller to select the theme.

This is the Swift code required to make the Alert Sheet in your iOS app development

 let uiAlertControl = UIAlertController(title: "Theme", message: "Please Select the Theme", preferredStyle: .actionSheet)
            uiAlertControl.addAction(UIAlertAction(title: "Dark Theme", style: .default, handler: { (_) in
                print("Dark Theme")
              })
            )
        
            uiAlertControl.addAction(UIAlertAction(title: "Light Theme", style: .default, handler: { (_) in
                print("Light Theme")
              })
            )
        
        uiAlertControl.addAction(UIAlertAction(title: "Autumn Theme", style: .default, handler: { (_) in
            print("Autumn Theme")
        })
        )
        
        
      
        uiAlertControl.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
        self.present(uiAlertControl, animated: true, completion: nil)