Show a fullscreen modal with a spinner when clicking button

2306 views ios

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?

answered question

1 Answer


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)

posted this

Have an answer?


Please login first before posting an answer.