PopOver Menu IOS Swift

0

I'm trying to make a menu PopOver similar to WhatsApp but to no avail. I wanted to make a menu similar to the one below.

The only menu% w / w I can do is with the white background and occupy the entire screen even though it is PopOver .

    
asked by anonymous 10.09.2016 / 15:37

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()
}
    
11.09.2016 / 07:51