How to hide title/message frame in a UIAlertController?

后端 未结 5 621
粉色の甜心
粉色の甜心 2020-12-24 05:02

When using a UIAlertController, if I want to present a UIActionSheet with an empty title and an empty message, the frame for the expected placement

5条回答
  •  一生所求
    2020-12-24 05:41

    In swift 2.2, you can use code below and I have also changed the color of signout action button

            let actionSheet: UIAlertController = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)
    
        self.presentViewController(actionSheet, animated: true, completion: nil)
    
        let settingsActionButton: UIAlertAction = UIAlertAction(title: "Settings", style: .Cancel) { action -> Void in
            print("Settings Tapped")
        }
    
        reportActionSheet.addAction(settingsActionButton)
    
        let signOutActionButton: UIAlertAction = UIAlertAction(title: "Signout", style: .Default)
        { action -> Void in
            //Clear All Method
            print("Signout Tapped")
    
        }
    
        signOutActionButton.setValue(UIColor.redColor(), forKey: "titleTextColor")
    
        actionSheet.addAction(signOutActionButton)
    
        let cancelActionButton: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
            print("Cancel Tapped")
        }
    
        reportActionSheet.addAction(cancelActionButton)
    

提交回复
热议问题