i have been searching for a long time to make custom Alert Views myself. But there was no success. What i do is i design a view in the xib file in the story board and load it in the application but it just shows up like regular views. What i want to do is present this view as AlertController in iOS >= 8 using Swift 3. What i did is
let alert = Bundle.main.loadNibNamed("xib file to load", owner: self, options: nil)?.last as! UIView
// showAlert(alert: alert)
func showAlert(alert: UIView){
let windows = UIApplication.shared.windows
let lastWindow = windows.last
print(lastWindow)
alert.frame = CGRect(x: 0, y: 0, width: 150, height: 300)
alert.center = self.view.center
lastWindow?.addSubview(alert)
}
func removeAlert(alert: UIView){
alert.removeFromSuperview()
}
This just shows and hides the view. But i want it to present like UIAlertController. I want everything in the background dim a and only focus on this view. How can i achieve that. Please help me through this.