Popover menu IOS Swift

Asked

Viewed 122 times

0

I’m trying to make a menu PopOver similar to that of the WhatsApp but without success. I wanted to make a menu similar to the one below. menu

The only menu PopOver what I can do is with the white background and occupies the entire screen, even if PopOver.

  • Post code to facilitate response.

  • as told by the friend @rubStackOverflow put the code as ta calling this Popover

1 answer

2


What you need to implement is actually called Uialertcontroller:

func displayAlertMenu() {

    let alert = UIAlertController(title: "Selecione a origem", message: nil, preferredStyle: .actionSheet)

    let cameraAction = UIAlertAction(title: "Tirar Foto ou Filmar Video", style: .default) {
        action in
        // call display camera method
    }

    let galleryAction = UIAlertAction(title: "Escolher Foto Existente", style: .default) {
        action in
        // call display gallery method
    }

    let cancelAction = UIAlertAction(title: "Cancelar", style: .cancel) {
        action in
        print("user tapped the cancel button")
    }

    alert.addAction(cameraAction)
    alert.addAction(galleryAction)
    alert.addAction(cancelAction)

    present(alert, animated: true, completion: nil)
}

And call the method when your view appears or at the push of a button:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    displayAlertMenu()
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.