## Introduction
Welcome to the documentation for the **SpButton** framework! Here, you will find all the necessary information to maximize the potential of this powerful library for iOS development.
## Installation
To install the SpButton framework, you have a few options:
1. **CocoaPods**: Add the following line to your Podfile and run `pod install`:
“`ruby
pod ‘SpButton’
“`
2. **Carthage**: Add the following line to your Cartfile and run `carthage update`:
“`
github “spprc/sp-button”
“`
3. **Manual**: You can also integrate the framework manually by following these steps:
– Download the latest framework release from the [GitHub repository](https://github.com/spprc/sp-button/releases).
– Drag and drop the framework file into your Xcode project.
– Make sure to add it to your project target.
## Usage
SpButton provides a straightforward way to create custom buttons with various styles and animations. By using the provided properties and methods, you can create visually appealing buttons that enhance the user experience.
To get started, follow these steps:
1. Import the framework in your Swift file:
“`swift
import SpButton
“`
2. Initialize a SpButton object:
“`swift
let spButton = SpButton(frame: CGRect(x: 0, y: 0, width: 100, height: 40))
“`
3. Customize the button’s appearance using the available properties, such as background color, font, border style, and more:
“`swift
spButton.backgroundColor = .blue
spButton.setTitle(“Submit”, for: .normal)
spButton.setTitleColor(.white, for: .normal)
spButton.cornerRadius = 10
spButton.highlightBackgroundColor = .lightGray
// Additional customizations…
“`
4. Add the button to your view hierarchy:
“`swift
view.addSubview(spButton)
“`
## Additional Features
### Animation Support
SpButton provides built-in animation support for various scenarios. You can animate button taps, long presses, or define your own custom animations. For example:
“`swift
// Configure a tap animation
spButton.tapAnimation = .pop
// Configure a long press animation
spButton.longPressAnimation = .shake
// Perform a custom animation
spButton.performCustomAnimation {
// Define your custom animation code here
}
“`
### Button Actions
You can easily associate actions with the SpButton using the `addAction` method. This way, you can define custom behaviors for when the button is tapped, long-pressed, or when a certain event occurs:
“`swift
spButton.addAction(.touchUpInside) {
// Define actions to be executed upon tap
}
spButton.addAction(.touchDown) {
// Define actions to be executed while button is being pressed
}
spButton.addAction(.longPress) {
// Define actions to be executed upon long press
}
“`
### Accessibility Support
SpButton fully supports accessible features, allowing users with disabilities to interact with your app effortlessly. You can customize accessibility properties such as the button’s label, traits, and hints:
“`swift
spButton.accessibilityLabel = “Submit Button”
spButton.accessibilityTraits = [.button]
spButton.accessibilityHint = “Double tap to submit the form”
“`
## Conclusion
Congratulations! You are now equipped with the knowledge needed to utilize the SpButton framework effectively. Experiment with the different customization options and explore the animation support to enhance user interaction within your iOS applications. For a comprehensive reference, please consult the [framework documentation](https://cocoadocs.org/docsets/spbutton).
If you encounter any issues or have questions, feel free to reach out to the [support team](mailto:support@spbutton.com). Happy coding!