Welcome to the documentation for the ReactionButton library! This library allows you to easily add fun and interactive reaction buttons to your iOS app. With ReactionButton, users can express their feelings or reactions to content with just a tap. Let’s get started!
Installation
To install ReactionButton in your project, you have two options:
- Using CocoaPods:
pod 'ReactionButton'
- Manual installation:
- Download the ReactionButton library.
- Unzip the downloaded file, and find the
ReactionButton.swift
file. - Add the
ReactionButton.swift
file to your Xcode project.
Usage
Using ReactionButton is quite simple. Follow the steps below to get started:
1. Import the library
import ReactionButton
2. Create a ReactionButton instance
let reactionButton = ReactionButton(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
3. Set reaction options
You can set the available reaction options for the button. This is a list of emojis available for users to react with. Here is an example:
reactionButton.reactionOptions = ["π", "π", "π"]
4. Handle reactions
You can handle a user’s reaction by assigning a closure to the onReactionSelection
property of the button. For example:
reactionButton.onReactionSelection = { reaction in
// Reaction selected, perform the desired action
print("Selected reaction: \(reaction)")
}
5. Add the button to your view
You can now add the reactionButton
to your view as a subview. For example:
view.addSubview(reactionButton)
Customization
ReactionButton provides several customization options to style the button according to your app’s design:
Appearance
You can customize the button’s appearance by modifying the following properties:
buttonBackgroundColor: UIColor
: Set the background color of the button.buttonTextColor: UIColor
: Set the text color of the button.buttonCornerRadius: CGFloat
: Set the corner radius of the button.
Size and Position
You can control the size and position of the button by modifying its frame
or using Auto Layout constraints.
Support and Feedback
For any questions or issues, please open an issue on GitHub. Your feedback is highly appreciated.