mgSegmentedProgressBar is a lightweight and customizable progress bar for iOS, built with Swift. It allows you to display progress in segmented form, making it suitable for scenarios where progress needs to be tracked in multiple stages.
Installation:
- Open your Xcode project.
- Select the target you want to add mgSegmentedProgressBar to.
- Go to “File” > “Swift Packages” > “Add Package Dependency”.
- Enter the following URL: https://github.com/magi82/mgSegmentedProgressBar.git
- Click “Next” and select the version you want to install.
- Click “Next” and Xcode will resolve the package and add it to your project.
Usage:
To use mgSegmentedProgressBar in your iOS project, follow these steps:
- Import the framework in your Swift file:
import mgSegmentedProgressBar
- Create an instance of mgSegmentedProgressBar:
let progressBar = mgSegmentedProgressBar(frame: CGRect(x: 0, y: 0, width: 200, height: 20))
- Set the total number of segments:
progressBar.totalSegments = 4
- Set the progress for each segment:
progressBar.setProgress(forSegment: 0, progress: 0.25)
progressBar.setProgress(forSegment: 1, progress: 0.5)
progressBar.setProgress(forSegment: 2, progress: 0.75)
progressBar.setProgress(forSegment: 3, progress: 1.0)
- Add the progress bar to your view:
view.addSubview(progressBar)
- Customize the appearance of the progress bar as per your requirements.
Customization:
mgSegmentedProgressBar provides various customization options to match your app’s design:
- segmentTintColor: Allows you to set the color of the progress segments.
- unfilledSegmentsColor: Allows you to set the color of the unfilled segments.
- cornerRounding: Lets you specify the corner rounding of the progress segments.
Use the following syntax to customize the progress bar:
progressBar.segmentTintColor = UIColor.blue
progressBar.unfilledSegmentsColor = UIColor.lightGray
progressBar.cornerRounding = 8
Requirements:
- iOS 11.0+
- Xcode 11.0+
- Swift 5.0+
License:
mgSegmentedProgressBar is released under the MIT License. See LICENSE for details.