How to reproduce Apple's alert-like views

Viewed 201

I am struggling the last couple of days to figure out if these alerts are part of UIKit or just a private custom view. I don't even know how they properly called. The UI team have asked for an alert that looks like the one appears in Apple's News and Podcast apps. See screenshots below.

enter image description here enter image description here

2 Answers

Apple's code to perform this is not part of UIKit. It will need to be implemented by you! I made a framework to do just this on GitHub called AOModalStatusView (https://github.com/alecdoconnor/AOModalStatusView).

The easiest way to do this would be with a custom view presented modally and with the presentation style set to "over current context" so that what is behind the view shows through. Inside the view create a square that is centered on the view. Give it rounded corners and a specific width and height. In order to get the blurred background you should use Apple's "Visual Effects View with Blur" or "Visual Effects View with Blur and Vibrancy." (https://shrikar.com/ios-development-tutorial-visual-blur-with-uivisualeffectview/)

In the view controller for this view, set a timer shortly in viewDidAppear(..) that will run dismiss(animated: true, completion: nil)

Related