iOS 进度条:VAProgressCircle
VAProgressCircle 是 iOS 一款显示加载进度的 UIview。
Example Setup
- Clone the repo and drag the Classes folder into your project. This should include VAProgressCircle.h/.m, and UIProgressLabel.h/.m
- Either create a VAProgressCircle using the- (id)initWithFrame:(CGRect)framemethod or drag and drop a UIView into your Interface Builder, subclass it to VAProgressCircle, and link it up to a property in your UIViewController
Here is the snippet of code slightly modified from the example app included in the repo. This shows how to initalize and add a VAProgressChart to your UIViewController using- (id)initWithFrame:(CGRect)frame
self.circleChart = [[VAProgressCircle alloc] initWithFrame:CGRectMake(50, 60, 250, 250)]; [self.view addSubview:self.circleChart];
Documentation
General
- VAProgressChart only supports opaque colors at the current release. Using any non-opaque colors could cause unwanted behavior
Methods
- (void)setProgress:(int)progress
The bread and butter method. Takes the current state of the VAProgressCircle and updates the circle to the progress that was passed
- (void)setColor:(UIColor *)color
Sets the color for all the relevant properties of the circle. This includes circleColor, accentLineColor, and numberLabelColor. Also sets the circleHighlightColor by taking the(UIColor *)colorand making it 20% lighter
- (void)setTransitionColor:(UIColor * )transitionColor
Sets the transition color for all the relevant properties of the circle. This includes circleTransitionColor, accentLineTransitionColor, and numberLabelTransitionColor. Also sets the circleHighlightTransitionColor by taking the(UIColor *)transitionColorand making it 20% lighter
- (void)setColor:(UIColor * )color withHighlightColor:(UIColor *)highlightColor
Functions similar to- (void)setColor:(UIColor *)colorbut allows the specification of a highlightColor
- (void)setTransitionColor:(UIColor * )color withHighlightTransitionColor:(UIColor *)highlightColor
Functions similar to- (void)setTransitionColor:(UIColor *)transitionColorbut allows the specification of a highlightColor
Properties
VAProgressCircleColorTransitionType transitionType
Should be set toVAProgressCircleColorTransitionTypeGradualif you want the spinner to transition to a second color as it approaches 100%. Defaults toVAProgressCircleColorTransitionTypeNone
VAProgressCircleRotationDirection rotationDirection
Designates which way the progress will rotate around the VAProgressChart. Defaults toVAProgressCircleRotationDirectionCounterClockwise
float animationSpeed
Designates how fast the animation should animate. Defaults to1.0f
BOOL shouldShowAccentLine
Designates whether or not an accent line should be allocated and animated every time a progress piece reaches the outer circle. Defaults toYES
BOOL shouldShowFinishedAccentCircle
Designates whether or not the VAProgressCircle will create a full accent circle when it reaches 100%. Defaults toYES
BOOL shouldHighlightProgress
Designates whether or not a progress piece will highlight when it reaches the outer circle. Defaults toYES
BOOL shouldNumberLabelTransition
If transitionType is set toVAProgressCircleColorTransitionTypeGradual, shouldNumberLabelTransition specifies if the number label should change color along with the rest of the VAProgressCircle. Defaults toYES
UIColor *circleColor
Designates what color the outer circle should be. Defaults toVADefaultGreen
UIColor *accentLineColor
Designates what color line the VAProgressCircle generates as a progress piece reaches the outer circle. Defaults toVADefaultGreen
UIColor *numberLabelColor
Designates the color of the number label. Defaults toVADefaultGreen
UIColor *circleHighlightColor
Designates the highlight color of the progress pieces ifshouldHighlightProgressis set toYES. Defaults toVADefaultGreen
UIColor *circleTransitionColor
Designates what color the outer circle should transition to as it approaches 100%. Defaults toVADefaultBlue
UIColor *accentLineTransitionColor
Designates what color line the VAProgressCircle generates should transition to as it approaches 100%. Defaults toVADefaultBlue
UIColor *numberLabelTransitionColor
Designates the color of the number label should transition to as it approaches 100%. Defaults toVADefaultBlue
UIColor *circleHighlightTransitionColor
Designates the transition highlight color of the progress pieces as the VAProgressCircle approaches 100% ifshouldHighlightProgressis set toYES. Defaults toVADefaultBlue。