ShAlertViewBlocks
Description:
ShAlertViewBlocks is a lightweight and easy-to-use library for displaying alert views and action sheets with blocks in iOS applications. It provides a more convenient way to handle user interactions and actions triggered by alert views or action sheets.
Requirements:
- iOS 7.0+
- ARC enabled
Installation:
To install ShAlertViewBlocks, you have multiple options:
- Manual:
- Download the source files from the GitHub repository.
- Add the ShAlertViewBlocks folder to your Xcode project.
- CocoaPods:
- Add `pod ‘ShAlertViewBlocks’` to your Podfile.
- Run `pod install` from the Terminal.
Usage:
To start using ShAlertViewBlocks, follow these steps:
- Import the ShAlertViewBlocks header file:
- Create an instance of the ShAlertViewBlocks class:
- Show an alert view:
- Show an action sheet:
import ShAlertViewBlocks
let alertView = ShAlertViewBlocks()
alertView.showAlert(title: "Alert View", message: "This is a sample alert view.", cancelButtonTitle: "Cancel", otherButtonTitles: ["OK"]) { (buttonIndex) in
// Handle button tapped events
if buttonIndex == 0 { // Cancel button tapped
// Do something
}
else if buttonIndex == 1 { // OK button tapped
// Do something else
}
}
alertView.showActionSheet(title: "Action Sheet", cancelButtonTitle: "Cancel", destructiveButtonTitle: "Delete", otherButtonTitles: ["Option 1", "Option 2"]) { (buttonIndex) in
// Handle button tapped events
if buttonIndex == 0 { // Cancel button tapped
// Do something
}
else if buttonIndex == 1 { // Delete button tapped
// Do something else
}
else if buttonIndex == 2 { // Option 1 tapped
// Do another thing
}
else if buttonIndex == 3 { // Option 2 tapped
// Do something completely different
}
}