Home

Awesome

Version License Platform Carthage compatible Analytics

If you use MBCircularProgressBar, please tell me and I will add your app here.

Usage

To run the example project, clone the repo, and run pod update from the Example directory first.

Installation

Cocoapods

MBCircularProgressBar is available through CocoaPods.

To install it, simply add the following lines to your Podfile:

use_frameworks!
pod "MBCircularProgressBar"

Installation with Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate MBCircularProgressBar into your Xcode project using Carthage, specify it in your Cartfile:

github "MatiBot/MBCircularProgressBar"

Run carthage update to build the framework and drag the built MBCircularProgressBar.framework into your Xcode project.

Directly

You can also download the MBCircularProgressBar{View,Layer}.{m,h} files into your project directly

Properties

Property nameProperty typeDescriptionRange
valueCGFloatThe value to be displayed in the center[0,maxValue]
maxValueCGFloatThe maximum possible value, used to calculate the progress (value/maxValue)[0,∞)
showValueStringBOOLShould show value string
showUnitStringBOOLShould show unit string
valueFontNameNSStringThe name of the font of the value stringAny valid font name
valueFontSizeCGFloatThe font size of the value text[0,∞)
valueFontNameNSStringThe name of the font of the unit stringAny valid font name
unitFontSizeCGFloatThe font size of the unit text[0,∞)
unitStringNSStringThe string that represents the units, usually %
fontColorUIColorThe color of the value and unit text
decimalPlacesNSIntegerNumber of decimal places of the value[0,∞)
progressRotationAngleCGFloatProgress bar rotation (Clockewise)[0,100]
progressAngleCGFloatSet a partial angle for the progress bar[0,100]
progressLineWidthCGFloatThe width of the progress bar (user space units)[0,∞)
progressColorUIColorThe color of the progress bar
progressStrokeColorUIColorThe color of the progress bar frame
progressCapTypeNSIntegerThe shape of the progress bar cap{kCGLineCapButt=0, kCGLineCapRound=1, kCGLineCapSquare=2}
emptyLineWidthCGFloatThe width of the background bar (user space units)[0,∞)
emptyLineColorUIColorThe color of the background bar
emptyCapTypeCGFloatThe shape of the background bar cap{kCGLineCapButt=0, kCGLineCapRound=1, kCGLineCapSquare=2}
textOffsetCGPointThe offset to apply to the unit / value text(0,0) = center of the circle

Animation

In order to animate a change in the progress bar you should nest the value property manipulation in a [UIView animateWithDuration:] method

    [UIView animateWithDuration:1.f animations:^{
        self.progressBar.value = 55.f;
    }];

References

[iOS][Swift] MBCircularProgressBar で円形のプログレスバーを実現 by @cocominap (in Japanese)

Author

Mati Bot, os@mati.bot, @b0tnik

Apps that use it:

20 Hours

License

MBCircularProgressBar is available under the MIT license. See the LICENSE file for more info.