1、获取电池电量
/**
获取设备电量
@return 电量百分比
*/
+ (CGFloat)getBatteryQuantity
{
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
return [[UIDevice currentDevice] batteryLevel];
}
2、获取电池状态
/**
获取电池状态
@return 电池状态 UIDeviceBatteryStateUnknown:无法取得充电状态情况
UIDeviceBatteryStateUnplugged:非充电状态
UIDeviceBatteryStateCharging:充电状态
UIDeviceBatteryStateFull:充满状态(连接充电器充满状态)
*/
+ (UIDeviceBatteryState)getBatteryStauts
{
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
return [UIDevice currentDevice].batteryState;
}
参考地址:http://www.cocoachina.com/ios/20161130/18229.html