|ReleasedLast Release||Dec 2014|
Maintained by Pierre Dulac.
Presents values in a custom gauge-style meter view with delightful animations
It should be easy to fill a shape with a color, to visually reflect a percentage.
There is plenty of examples where it can be useful:
Clone the repo and install CocoaPods dependencies.
$ git clone https://github.com/dulaccc/DPMeterView.git $ cd DPMeterView/Example $ pod install $ open Example.xcworkspace
Then select the correct active scheme
Example (if something else like
Pod-DPMeterViewTests was selected).
And your good to run the app on the Simulator or a Device.
#import "DPMeterView.h" #import "UIBezierPath+BasicShapes.h" DPMeterView *fiveStarsShape = [[DPMeterView alloc] init]; [fiveStarsShape setFrame:CGRectMake(0, 0, 200, 40)]; [fiveStarsShape setMeterType:DPMeterTypeLinearHorizontal]; [fiveStarsShape setShape:[UIBezierPath stars:5 shapeInFrame:fiveStarsShape.bounds].CGPath];
[fiveStarsShape setProgress:0.6 animated:YES];
And a nice animation will update the view.
Not a single image pixel !
In the example above I'm just using a
UIBezierPath that is included in the category
UIBezierPath+BasicShapes. Feel free to fork the project and add other shapes you think it'd be great to have.
You can use any shape you want, the class
DPMeterView uses the
CGPath as a mask.
to try this feature you need to run the
Exampleproject on a device because the simulator doesn't provide
0.0.1version otherwise the
commonInitmethod won't be called. Instead, use the
yawobtained from the
CoreMotionacceleration quaternion is restrained to the interval
[-PI/2, PI/2], because of the definition of
arcsinused to compute it. It would be even better if we find a way to extend it to the complete interval
[-PI, PI], but I'm not a "quaternion master" ^^
DPMeterViewshape can be entirely filled whereas it is not at a 100% progression, depends on the shape…
progressTintColorthat can evolve with the
progressvalue, like in a heat map scale.
.svgfile into a
UIBezierPathdirectly, avoiding the burden of creating a UIBezierPath by hand. (the current work around is to use the great PaintCode application)
DPMeterView is available under the MIT license. See the LICENSE file for more info.