Introduction
Welcome to the documentation page for PTAlertView. Here, you will find information on how to use PTAlertView, a customizable and feature-rich alert view library for your iOS applications. With PTAlertView, you can create and display alerts, action sheets, and toast notifications with ease.
Installation
Requirements
- iOS 9.0+
- Xcode 11.0+
- Swift 5.0+
Installation via Cocoapods
To install PTAlertView using Cocoapods, add the following line to your Podfile:
pod 'PTAlertView'
Then, run the following command:
pod install
Usage
Importing the Library
To use PTAlertView in your project, import the library:
import PTAlertView
Creating Alerts
To create an alert, use the following code snippet:
let alert = PTAlertView(title: "Alert Title", message: "Alert message goes here") alert.addAction(title: "OK", style: .default, handler: { // Handle OK button action }) alert.present()
Creating Action Sheets
To create an action sheet, use the following code snippet:
let actionSheet = PTActionSheet(title: "Action Sheet Title", message: "Action sheet message goes here") actionSheet.addAction(title: "Action 1", style: .default, handler: { // Handle Action 1 }) actionSheet.addAction(title: "Action 2", style: .default, handler: { // Handle Action 2 }) // Add more actions as needed actionSheet.present()
Creating Toast Notifications
To display a toast notification, use the following code snippet:
PTToastView.showToast(message: "Toast message goes here")
Customization
PTAlertView provides various customization options to match your app’s look and feel. Below are some of the customization options:
Alert Customization
To customize the alert appearance, use the following properties:
titleColor
: Set the color for the alert titlemessageColor
: Set the color for the alert messagealertColor
: Set the background color for the alert
Action Sheet Customization
To customize the action sheet appearance, use the following properties:
titleColor
: Set the color for the action sheet titlemessageColor
: Set the color for the action sheet messageactionColor
: Set the color for the action sheet actions
Toast Customization
To customize the toast notification appearance, use the following properties:
backgroundColor
: Set the background color for the toasttextColor
: Set the color for the toast text
Examples
Here are some examples to demonstrate the usage of PTAlertView:
Example 1: Simple Alert
let alert = PTAlertView(title: "Welcome", message: "Thank you for using our app!") alert.addAction(title: "OK") alert.present()
Example 2: Action Sheet with Custom Actions
let actionSheet = PTActionSheet(title: "Options", message: "Choose an option") actionSheet.addAction(title: "Option 1", style: .default, handler: { // Handle Option 1 }) actionSheet.addAction(title: "Option 2", style: .default, handler: { // Handle Option 2 }) actionSheet.addAction(title: "Cancel", style: .cancel) actionSheet.present()
Conclusion
PTAlertView provides a simple and customizable way to display alerts, action sheets, and toast notifications in your iOS applications. With its easy-to-use interface and customization options, you can create visually appealing and interactive alerts for your users. Happy coding!