Move UIAlertView

I want just a UIAlertViewat the bottom of the screen when opening the ViewController.

Now I am creating a warning view, showing it after 2 seconds and hiding the warning.
However, the type of warning appears only in the center of the screen.

How to move it to the bottom of the screen?

Here is my code:

let alert = UIAlertController(title: "", message: "Please Swipe To Refresh After 2 seconds", preferredStyle: .alert)
alert.view.frame.origin.x = 150
alert.view.frame.origin.y = 250
self.present(alert, animated: true, completion: nil)
let indicator = UIActivityIndicatorView(frame: alert.view.bounds)
indicator.autoresizingMask = [.flexibleWidth, .flexibleHeight]
alert.view.addSubview(indicator)
indicator.isUserInteractionEnabled = false 
indicator.startAnimating()       
let when = DispatchTime.now() + 2
DispatchQueue.main.asyncAfter(deadline: when) {
    alert.dismiss(animated: true, completion: nil)
}
+4
source share
2 answers

You cannot move UIAlertControllerwith his set of presentation style, and even if the workaround will not be used. To achieve what you want, you have different options:

  • UIView, show , -
  • UIViewController UIPresentationController, , iOS
  • github, this
+5

(.... , preferredStyle: .actionSheet) UIAlertController

0

Source: https://habr.com/ru/post/1680294/


All Articles