CocoaPods trunk is moving to be read-only. Read more on the blog, there are 9 months to go.

JZBattery 1.2.2

JZBattery 1.2.2

Maintained by Jiahao Zhu.



JZBattery 1.2.2

  • By
  • 朱嘉皓

JZBattery

CI Status Version License Platform

Example

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

Requirements

Minimum iOS Target: 9.0

Installation

JZBattery is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'JZBattery'

Usage

JZBatteryView can be laid out via both the frame based layout and auto layout. It is can also be used in .xib, you can just simply place a UIView and change its class to JZBatteryView.

/* It is not necessary to be initialized with a frame */
let battery = JZBatteryView(/*frame: <any CGRect>*/)
view.addSubview(battery)

Property

The properties are listed below:

Property Access Right Description
currentBatteryState Read-only It returns the current battery state.
currentBatteryLevel Read-only It returns the current battery level, scaled from 0 to 1.
widthToHeightRatio Readwrite It represents the width : height ratio of the battery, the default value is 2.5.
style Readwrite It represents the color style of the battery, the default value is .dark.
batteryStateChangeCallback Readwrite It will be called after receiving a notification for the change in battery state.
batteryLevelChangeCallback Readwrite It will be called after receiving a notification for the change in battery level.

Author

朱嘉皓, [email protected]

License

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