ProgressBar
public class ProgressBar : NSObject
An animatable and customizable progress bar.
-
Initializes the progress bar instance and (optionally) based on the given progress bar’s track configuration(s) and bar configuration.
trackColourThe number of elements in this array will determine whether the progress bar’s track, would be a solid colour (single element), or gradient colours (more than 1 element).
barColourThe number of elements in this array will determine whether the progress bar’s bar, would be a solid colour (single element), or gradient colours (more than 1 element).
configurationsThe
PBConfigurationtakes in 2 keys which are.trackand.bar. Both represents the progress bar’s track and bar elements, respectively.The
PBConfiguration.trackaccepts an Array ofPBTrackConfigurations which will:- Configure the progress bar’s track display.
- Determine the number of progress bar that will be displayed. (1 track configuration represents 1 progress bar track)
On the other hand, the
PBConfiguration.baraccepts an object of typePBBarConfigurationwhich will configure the progress bar’s bar display.Similar with the progress bar’s track configurations, the progress bar’s bar configuration can also be customized, or used with default values.
Declaration
Swift
public init(trackColour: [UIColor], barColour: [UIColor], configurations: [PBConfigurations : Any] = [:])Parameters
trackColourAn array of the progress bar’s track UIColor.
barColourAn array of the progress bar’s bar UIColor.
configurationsThe
PBConfigurationthat takes in the configurations for the progress bar’s track and bar. (optional)
-
Sets up the progress bar within the given container view.
This method should only be called ONCE, and only in
viewDidLayoutSubviewsto ensure thecontainerhas already been laid out correctly by AutoLayout.Declaration
Swift
public func setupProgressBar(in container: UIView)Parameters
containerThe container
viewto initialize the progress bar in. -
Animates the progress bar from
0until the given percentage value (in decimals) of the total width of the progress bar container view. Animation duration defaults to 0.75.This method should only be called after calling
setupProgressBar(in:)to ensure the progress bar is already initialized.Declaration
Swift
public func setProgressBarValue(to value: CGFloat, duration: Double = 0.75)Parameters
valueThe percentage (in decimals) for the progress bar’s width to expand to, within a minimum value of 0, and a maximum value of 1.
durationThe animation duration to animate the progress bar. (optional)
ProgressBar Class Reference