support iOS 13 dark mode
This commit is contained in:
parent
538d5cc959
commit
d4c9aeb84a
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue