## Introduction
This page provides documentation for the **HGCircularSlider** library. HGCircularSlider is a customizable circular slider control for iOS applications. It allows users to select a value by interacting with a circular slider interface.
## Installation
To install HGCircularSlider in your iOS project, you can choose one of the following methods:
### CocoaPods
1. Open your project directory in Terminal.
2. Run the command: `pod init` (if you haven’t already initialized a podfile).
3. Open the Podfile created in your project directory.
4. Add the following line to your Podfile: `pod ‘HGCircularSlider’, ‘~> 1.0’`.
5. Save the Podfile and run the command: `pod install`.
6. Close your Xcode project and open the newly generated `.xcworkspace` file.
7. Import the library into your project using `import HGCircularSlider`.
### Manual Installation
1. Download the latest release of HGCircularSlider from the [GitHub repository](https://github.com/HamzaGhazouani/HGCircularSlider).
2. Drag and drop the `HGCircularSlider` folder into your Xcode project.
3. In Xcode, select your project in the Project Navigator.
4. Go to the General tab and scroll down to the *Embedded Binaries* section.
5. Click the ‘+’ button and choose the `HGCircularSlider.framework` file.
6. Import the library into your project using `import HGCircularSlider`.
## Usage
### Creating a Circular Slider
To create a circular slider, follow these steps:
“`swift
// 1. Import the library
import HGCircularSlider
// 2. Create an instance of the HGCircularSlider control
let circularSlider = HGCircularSlider(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
// 3. Customize the appearance and behavior of the circular slider
circularSlider.value = 50
circularSlider.minimumValue = 0
circularSlider.maximumValue = 100
// 4. Add the circular slider to your view hierarchy
view.addSubview(circularSlider)
“`
### Customization
HGCircularSlider provides various customization options to tailor the appearance and functionality of the circular slider. Some of the available customization properties are:
– `minimumValue`: The minimum selectable value of the slider.
– `maximumValue`: The maximum selectable value of the slider.
– `startAngle`: The starting angle of the circular slider.
– `endAngle`: The ending angle of the circular slider.
– `thumbTintColor`: The color of the thumb (selector) on the circular slider.
– `diskFillColor`: The color of the filled portion of the circular slider.
– `diskColor`: The color of the unfilled portion of the circular slider.
– `trackColor`: The color of the track that the thumb moves over.
– `lineWidth`: The width of the track and the disk of the circular slider.
You can customize these properties using the following methods and properties:
“`swift
circularSlider.propertyName = value // Replace propertyName with the desired property name from the list above
“`
## Delegate
HGCircularSlider provides a delegate protocol `HGCircularSliderDelegate` that allows you to respond to changes in the slider’s value. To use the delegate, implement the following methods in your class:
“`swift
extension YourViewController: HGCircularSliderDelegate {
func circularSliderValueChanged(_ circularSlider: HGCircularSlider, value: Float, isTracking: Bool) {
// Handle value changes in the circular slider here
}
func circularSliderThumbReleased(_ circularSlider: HGCircularSlider) {
// Handle the release of the slider’s thumb here
}
}
“`
Then, assign your view controller as the circular slider’s delegate:
“`swift
circularSlider.delegate = self
“`
## Additional Resources
– GitHub Repository: [https://github.com/HamzaGhazouani/HGCircularSlider](https://github.com/HamzaGhazouani/HGCircularSlider)
– Official Documentation: [https://cocoadocs.org/docsets/hgcircularslider](https://cocoadocs.org/docsets/hgcircularslider)