You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Use the native `Color`,`NSColor`,`UIColor.colorName` where possible.
89
+
- Add #ifos(iOS) /#ifos(macOS) where needed.
90
+
-Example (works on almost all versions):
91
+
```swift
92
+
/// A color that represents the system-provided pink color.
93
+
publicstaticvar systemPink: Color {
94
+
#ifos(iOS) ||os(tvOS)
95
+
Color(UIColor.systemPink)
96
+
#elseifos(macOS)
97
+
Color(NSColor.systemPink)
98
+
#else
99
+
BaseColor.systemPink
100
+
#endif
101
+
}
102
+
```
103
+
- Example 2 (works from a specific iOS/macOS version):
104
+
```swift
105
+
/// A color that represents the system-provided cyan color.
106
+
publicstaticvar systemCyan: Color {
107
+
#ifos(iOS) ||os(tvOS)
108
+
if#available(iOS15.0, *) {
109
+
Color(UIColor.systemCyan)
110
+
} else {
111
+
BaseColor.systemCyan
112
+
}
113
+
#elseifos(macOS)
114
+
if#available(macOS12.0, *) {
115
+
Color(NSColor.systemCyan)
116
+
} else {
117
+
BaseColor.systemCyan
118
+
}
119
+
#else
120
+
BaseColor.systemCyan
121
+
#endif
122
+
}
123
+
```
124
+
77
125
## Contact
78
126
79
127
We can getin touch via [Mastodon](https://mastodon.social/@0xWDG), [Twitter/X](https://twitter.com/0xWDG), [Discord](https://discordapp.com/users/918438083861573692), [Email](mailto:[email protected]), [Website](https://wesleydegroot.nl).
0 commit comments