-1

Please tell me how can I make such an alert as in the picture?

I added this code. But how can I position the elements in the right places?

alert = UIAlertController(title: NSLocalizedString("AttendUpload", comment: "Идет загрузка файла, пожалуйста подождите"), message: "", preferredStyle: .alert)


    uploadingIndicator = UIActivityIndicatorView(frame: CGRect(x: 10, y: 5, width: 50, height: 50))
    uploadingIndicator!.hidesWhenStopped = true
    uploadingIndicator!.style = UIActivityIndicatorView.Style.whiteLarge
    uploadingIndicator!.startAnimating() 

    uploadingPercentage = UILabel(frame: CGRect(x: 10, y: 10, width: 200, height: 50))
    uploadingPercentage?.text = "Загружено 0%"//NSLocalizedString("Uploaded", comment: "Загружено") + "0 %"
    uploadingPercentage?.font = UIFont.preferredFont(forTextStyle: .body)
    uploadingPercentage?.textColor = UIColor.red

    self.alert!.view.addSubview(uploadingIndicator!)
    self.alert!.view.addSubview(uploadingPercentage!)

    present(alert!, animated: true, completion: nil)

Alert picture

Alex Kirov
  • 29
  • 1
  • 8

1 Answers1

1

You shouldn't attempt to do this. From the docs:

The UIAlertController class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.

You should create your own view controller.

Mike Taverne
  • 9,156
  • 2
  • 42
  • 58