Tuesday, 19 December 2017

UIAlertColtroller Demo

step 1: Put UIButton on ViewController.
step 2: Give constraints and IBAction of UIButton.
step 3: In IBAction of UIButton put following code. Like,

@IBAction func AlertButtonPressed(_ sender: UIButton) {
        let alert = UIAlertController(title: APP_NAME, message: "Hello", preferredStyle: .actionSheet)
        
        
        let actionOkay = UIAlertAction(title: "Yes", style: .default) { (action) in
            print("YES")
        }
        
        let actionCan = UIAlertAction(title: "No", style: .cancel) { (action) in
            print("No")
        }
        
        let actionCan1 = UIAlertAction(title: "Delete", style: .destructive) { (action) in
            print("Delete")
        }
       
        alert.addAction(actionCan)
        alert.addAction(actionOkay)
         alert.addAction(actionCan1)
        self.present(alert, animated: true, completion: nil)

    }

Thank you...

No comments:

Post a Comment