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.addAction(YesAction)

        myActionSheet.addAction(NoAction)

        

        

        myActionSheet.popoverPresentationController?.sourceView = self.btnCancell

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

        

        // present the action sheet

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

https://github.com/melihkeskin/Bilgeadam_Gun4_Odev

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: