我正在使用 swift 2.2 开发一个应用程序,在我的应用程序中,当用户点击该按钮时,我有一个按钮,警报视图将出现,其中包含垂直的四个按钮,一切正常,但警报视图出现在视图控制器的底部如何显示在视图控制器的中心。
注意:我不想显示任何标题和消息,我只需要显示四个按钮。
如果我使用这个:
let alert = UIAlertController(title: " ", message: "select colors", preferredStyle: UIAlertControllerStyle.Alert)
它有助于显示在视图控制器的中心,但没有标题和消息,它看起来并不好,所以我使用了以下代码
代码:
let alert = UIAlertController()
alert.addAction(UIAlertAction(title: "Red Color", style: UIAlertActionStyle.Default, handler: nil))
alert.addAction(UIAlertAction(title: "Blue Color", style: UIAlertActionStyle.Default, handler: nil))
alert.addAction(UIAlertAction(title: "Green Color", style: UIAlertActionStyle.Default, handler: nil))
alert.addAction(UIAlertAction(title: "Yellow Color", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)