If I want to create a pop up view in Android, say on clicking a button, a QR code will pop up and things behind will be blurred a bit, I called the Dialog class in Android/Java, which I think is more like a View in iOS.
May I know whether there is a class which is almost equivalent in iOS? I googled around and seems no one mention about that. While some might say I could use AlertController, I would say the experience is completely different. Dialog in Android can contain everything - text, buttons, images, layouts, you name it, while AlertController in iOS is literally just the alert and it does not expect you to do so much customization.
Can anyone illustrate the road ahead for me?
You use
UIAlertControllerin Swift.Example
Result
Breaking This Down
alertController. Set the title to"My Title"and the message.tintColor. This changes it to custom colors other than the default iOS blue tint.UIBlurEffect. "Tries" to mimic AndroidsAlertDialog. :)UIImageViewto thealertControlleras a sub viewcancelActionandokAction. Notice thestyle:property? This allows you to choose between.destructive, and.default..destructivemakes the button red-tinted, and.defaultleaves it as thealertController'stintColor.UIImageViews)alertController.addActionfunctions to add our buttons, andpresentit.DispatchQueue.main.async {}. This is useful if you want to show your dialog before the parentViewControlleris fully loaded. (E.G. You show your dialog in the.viewDidLoadfunction.