0

I have a login form that, when the user clicks on the submit button, I want to show a fullscreen modal with a white and slightly transparent background, and a spinner in the middle, while the app communicates with the server. I then want to hide that layout when the app gets a response from the server.

I have set up a view controller with the above layout (white background and spinner). However, I'm not sure how to show this view over the login view when the login button is clicked.

Here is the action I've made for the login button:

@IBAction func onSubmit(_ sender: Any) {

}

How do I show the view over the entire screen, that disables user interaction?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user9815123
  • 63
  • 1
  • 10
  • There are many ways you could implement this. For example you could create a view and add it on top of the current view, this new view would have the activity spinner and an opacity styled how you want it. – Axemasta Nov 04 '18 at 21:41

1 Answers1

0

This is really simple. Modals are presented full-screen by default.

If you want the view controller to show the contents from the view controller below, but blurred, then you need to add a UIVisualEffectView to your view controller. See this link for info on using UIVisualEffectView: Creating a blurring overlay view

Your code to present a modal can be as simple as:

let modal = storyboard.instantiateViewController(withIdentifier: "modal")
present(modal, animated: true)
Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • While valid, this probably isnt the best thing to do. Simply adding a view ontop of the current view would suffice and prevent the OP getting confused with where they are in the nav stack! – Axemasta Nov 04 '18 at 21:41