Creating an Action Sheet in Swift

Below code use what ever you want (buttonTap etc. )

let myActionSheet = UIAlertController(title: “Notice”, message: “Do you want to leave?”, preferredStyle: UIAlertControllerStyle.ActionSheet)


        // Yes action button

        let YesAction = UIAlertAction(title: “Yes”, style: UIAlertActionStyle.Default)


                (action) in  self.dismissVC()





        // No action button

        let NoAction = UIAlertAction(title: “No”, style: UIAlertActionStyle.Default) { (action) in

            print(“no action button tapped”)



        // add action buttons to action sheet





        myActionSheet.popoverPresentationController?.sourceView = self.btnCancell

        myActionSheet.popoverPresentationController?.sourceRect = self.btnCancell.bounds


        // present the action sheet

        self.presentViewController(myActionSheet, animated: true, completion: nil)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: