Simple view composed by a battery image and a view that fill the battery with the current battery level
Failed to load latest commit information.
ALBatteryView.xcodeproj New method to reload the animation of the battery Aug 21, 2013
.gitignore New gitignore and correct an error on README Aug 7, 2013 Updated README Aug 7, 2013

What is

This class allow you to show a battery image and fill it with the current real charge. The color of the fill view depends by the battery level.

alt text


The usage is simple. First, drag the ALBatteryView folder to your project. The folder contains ALBatteryView.h, ALBatteryView.m, Resource folder with the battery image and the UIView+ALQuickFrame category (

ALBatteryView *batteryView = [[ALBatteryView alloc] initWithFrame:CGRectMake(20, 40, 80, 80)];
[self.view addSubview:batteryView];
[batteryView setBatteryLevelWithAnimation:YES forValue:[UIDevice currentDevice].batteryLevelInPercentage inPercent:YES];

This will create a view of type ALBatteryView with the frame you want, will add it to the current view and will call the method to set the battery level. The batteryLevelInPercentage method is available thanks to a category of UIDevice declared in the header of ALBatteryView. This will animate the view filling the battery


The battery view can be maximum 128x128 (width, height), this is because the png is 256x256 pixels. The battery view has to be a square, so the width and the height have to be the same.


Licesed under the MIT License.