回答編集履歴
1
へんこう
test
CHANGED
@@ -1,3 +1,51 @@
|
|
1
|
+
変更
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```swift
|
6
|
+
|
7
|
+
extension NSApplication {
|
8
|
+
|
9
|
+
var isDarkMode: Bool {
|
10
|
+
|
11
|
+
if #available(macOS 01.14, *) {
|
12
|
+
|
13
|
+
guard let current = effectiveAppearance.bestMatch(from: [.aqua, .darkAqua]) else { return false }
|
14
|
+
|
15
|
+
return current == .darkAqua
|
16
|
+
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
return false
|
22
|
+
|
23
|
+
}
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
使い方
|
32
|
+
|
33
|
+
```swift
|
34
|
+
|
35
|
+
if NSApplication.shared.isDarkMode {
|
36
|
+
|
37
|
+
// Dark mode
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
----
|
48
|
+
|
1
49
|
[https://stackoverflow.com/questions/51672124/how-can-dark-mode-be-detected-on-macos-10-14](https://stackoverflow.com/questions/51672124/how-can-dark-mode-be-detected-on-macos-10-14)
|
2
50
|
|
3
51
|
この質問の承認された回答を参考にSwiftに書き直すと
|