About RMActionController
RMActionController is a versatile and customizable library for presenting custom action sheets and alert controllers in your iOS apps. It provides a lightweight and easy-to-use interface for displaying various types of actions and handles user interactions with them.
Key Features
- Supports various types of actions including buttons, destructive buttons, cancel actions, and custom actions.
- Customizable appearance and behavior to fit your app’s design.
- Allows grouping actions into multiple sections for better organization.
- Rich configuration options for each action, including title, image, text color, background color, and more.
- Supports both iPhone and iPad interfaces with automatic layout adjustments.
- Ability to add custom views to action sections for more flexibility.
- Handles user interactions through convenient delegate methods.
- Smooth and animated transition effects when presenting or dismissing.
- Compatible with Objective-C and Swift.
Installation
To integrate RMActionController into your iOS project, you can use CocoaPods or manually add the library files.
CocoaPods
- Add the following line to your podfile:
pod 'RMActionController'
- Run
pod install
command in your terminal. - Import the library in your project:
import RMActionController
Manual Installation
If you prefer not to use CocoaPods, you can manually add the library files to your project:
- Download the latest version of RMActionController.
- Drag and drop the library files into your Xcode project.
- Make sure to check the option “Copy items if needed” when prompted.
- Import the library in your project:
import RMActionController
Getting Started
To start using RMActionController, follow these steps:
1. Create an Instance
Create an instance of RMActionController in your view controller:
let actionController = RMActionController(style: .white)
2. Add Actions
Add the desired actions to the action controller:
let action1 = RMAction(title: "Action 1", style: .normal, handler: { _ in
// Handle action 1
})
actionController.addAction(action1)
let action2 = RMAction(title: "Action 2", style: .normal, handler: { _ in
// Handle action 2
})
actionController.addAction(action2)
// Add more actions as needed
3. Customize Appearance
Customize the appearance of the action controller, if desired:
// Example customization
actionController.view.tintColor = UIColor.red
actionController.titleLabel.text = "Choose an Action"
4. Present the Action Controller
Present the action controller in your view controller:
present(actionController, animated: true, completion: nil)
Delegate Methods
RMActionController supports several delegate methods that allow you to respond to user interactions and handle various actions. Implement the following methods in your view controller and set it as the delegate for the action controller:
actionController.delegate = self
You can then implement the delegate methods as needed:
func actionController(_ controller: RMActionController, didSelectAction action: RMAction) {
// Handle the selected action
}
func actionControllerDidDismissActionController(_ controller: RMActionController) {
// Perform necessary actions when action controller is dismissed
}
// Add more delegate methods as needed
Additional Resources
For more detailed information and advanced usage of RMActionController, please refer to the official documentation and sample app.