2017-04-12 56 views
1

我想用swift實現彈出式模式。我必須實現這樣的功能,以便根據用戶點擊的響應(是/否)再彈出一個窗口。如何實現這個 ? 任何幫助將非常有幫助。Modal在Swift中彈出3

+0

檢查這個庫可以幫助它https://github.com/MarioIannotta/MIBlurPopup –

回答

4

UIAlertController專爲此目的而設計。

 let alertController = UIAlertController(title: "Default AlertController", message: "A standard alert", preferredStyle: .Alert) 

     let cancelAction = UIAlertAction(title: "No", style: .Cancel) { (action:UIAlertAction!) in 
      println("you have pressed the No button"); 
      //Call another alert here 
     } 
     alertController.addAction(cancelAction) 

     let OKAction = UIAlertAction(title: "Yes", style: .Default) { (action:UIAlertAction!) in 
      println("you have pressed Yes button"); 
      //Call another alert here 
     } 
     alertController.addAction(OKAction) 

     self.presentViewController(alertController, animated: true, completion:nil) 
+0

我知道這個報告控制,但情況是我必須做出一個自定義模式彈出,我怎麼能實現定製彈出? – victorious

+1

簡單的做法是,將UIView放入透明背景。在其上添加一個視圖,用作彈出窗口。現在開始設計UIView。 –

+0

好的,這似乎是一個更好的方法。我一定會實現。謝謝:) – victorious