aznelite89 aznelite89 - 1 month ago 12
iOS Question

Facebook image pop up menu

i had tried to search for the way to achieve the menu through google/youtube etc and still can't found a way to achieve this.

How can i achieve the pop up menu almost like this? :-
enter image description here

any suggestion would be much appreciated.

Answer

You can use this code to get achieve this same. This is working with Swift 3 and XCode 8.

    let actionSheet: UIAlertController = UIAlertController.init(title: "Title of the action sheet", message: "Message to display", preferredStyle: .actionSheet)

    //Create and add the Cancel action
    let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .cancel) { action -> Void in
        //Just dismiss the action sheet
    }
    actionSheet.addAction(cancelAction)

    //Create and add first option action
    let savePictureAction: UIAlertAction = UIAlertAction(title: "Using Camera", style: .default) { action -> Void in
        // Write Save Method Here
    }
    actionSheet.addAction(savePictureAction)

    //Create and add a second option action
    let sendInMessenger: UIAlertAction = UIAlertAction(title: "Choose Existing Photo", style: .default) { action -> Void in
        // Write your code to Send In Messenger Here
    }
    actionSheet.addAction(sendInMessanger)

    //Create and add a third option action
    let dontLikePhoto: UIAlertAction = UIAlertAction(title: "Choose Existing Photo", style: .default) { action -> Void in
        // Write your code if you Don't like photo Here
    }
    actionSheet.addAction(dontLikePhoto)

    //Create and add a third option action
    let trunOnNotification: UIAlertAction = UIAlertAction(title: "Choose Existing Photo", style: .default) { action -> Void in
        // Write your code Turn on Notifications Here
    }
    actionSheet.addAction(trunOnNotification)

    //We need to provide a popover sourceView when using it on iPad
    actionSheet.popoverPresentationController?.sourceView = sender as? UIView

    //Present the AlertController
    self.present(actionSheet, animated: true, completion: nil)

Please note that this method is available from iOS 9.

Comments