LoginSignup
7
8

More than 5 years have passed since last update.

[Swift] バッテリー残量の表示

Last updated at Posted at 2015-09-04

やること

  1. バッテリーの監視を許可
  2. バッテリー残量を文字列に変換
BatteryLevel

    var battery: String?

    // 1. バッテリーの監視を許可
    UIDevice.currentDevice().batteryMonitoringEnabled = true

    // 2. バッテリー残量を文字列に変換
    battery = NSString(format: "%.2f", UIDevice.currentDevice().batteryLevel) as String

すみません、実機で動かさないと確認できないですm(_ _)m

7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8