我在做游戏。
如果手机的电池电量不足60%,则产量减量为60-当前电池电量的百分比
所以,我的问题是:
我可以获取有关iOS中电池电量百分比的信息吗?
最佳答案
NSArray *stateArray = @[@"Battery state is unknown",
@"Battery is not plugged into a charging source",
@"Battery is charging",
@"Battery state is full"];
NSString *status = [NSString stringWithFormat:@"Battery state: %@, Battery level: %0.2f%%",
stateArray[[UIDevice currentDevice].batteryState],
[UIDevice currentDevice].batteryLevel * 100];
NSLog(@"%@", status);
关于ios - 获取电池状态,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19197656/