diff --git a/CHANGELOG.md b/CHANGELOG.md index d355150..48657a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added +- support iOS 13 dark mode. + ## [1.3.9] - 2019-09-12 ### Fixed diff --git a/Sources/BatteryView.swift b/Sources/BatteryView.swift index 3c8473f..98dabbe 100644 --- a/Sources/BatteryView.swift +++ b/Sources/BatteryView.swift @@ -49,7 +49,7 @@ extension Int { /// label shown over battery when the level is undefined or out of range @IBInspectable open dynamic var noLevelText: String? = "?" - @IBInspectable open dynamic var borderColor: UIColor = .black { + @IBInspectable open dynamic var borderColor: UIColor = .foreground { didSet { bodyOutline.borderColor = borderColor.cgColor terminalOutline.borderColor = borderColor.cgColor @@ -181,7 +181,7 @@ extension Int { case .fullBattery: terminalOpening.backgroundColor = currentFillColor.cgColor case 0 ..< .fullBattery: - terminalOpening.backgroundColor = (backgroundColor ?? .white).cgColor + terminalOpening.backgroundColor = (backgroundColor ?? .background).cgColor default: terminalOpening.backgroundColor = noLevelColor.cgColor } @@ -214,3 +214,21 @@ extension CALayer { return CGPoint(x: frame.midX, y: frame.midY) } } + +extension UIColor { + static var background: UIColor { + if #available(iOS 13, *) { + return .systemBackground + } else { + return .white + } + } + + static var foreground: UIColor { + if #available(iOS 13, *) { + return .label + } else { + return .black + } + } +}