UIAlertController in Swift
UIAlertController is one of the most basic component of the app development, because using the UIAlertController to get the feedback, confirmation, choose between the options from the user, also we do alerts.
Components
- Title : The title of the alert.
- Alert Message : Descriptive text that provides more details about the reason for the alert.
- Alert Style : Indicating the type of alert to display.
- Alert Actions : The actions that the user can take in response to the alert or action sheet.
- Alert TextField : Text field displayed by the alert.
Alert Styles: Alert Or Action Sheet?
When creating your alert controller, you can choose between two options from enum UIAlertControllerStyle
- .alert : An alert displayed modally for the app.
- .actionSheet : An action sheet displayed in the context of the view controller that presented it.
Ready? Let’s go, 👨💻
Simple alert
Simple action sheet
Alert with distractive button
Alert with more than 2 buttons
Alert with UITextField
If you want to validate the input box, add delegate to the UITextField and you can validate as normally we do for others.
"Good software, like wine, takes time" - Joel Spolsky 🍷
Find it a good read?
Recommend this post (by clicking 👏 button) so other people can see it too…
reach me on Twitter Balaji Malliswamy