TabView {
Text("The First Tab")
.badge(10)
.tabItem {
Image(systemName: "1.square.fill")
Text("First")
}
Text("Another Tab")
.tabItem {
Image(systemName: "2.square.fill")
Text("Second")
}
Text("The Last Tab")
.tabItem {
Image(systemName: "3.square.fill")
Text("Third")
}
}
.font(.headline)
.accentColor(.orange) // don't work on macOS
此代碼適用于 iOS:

在 macOS 設定視圖上運行:

這是系統默認設定:

在 macOS 12.4 (21F79) 和 iOS 15.4 上進行測驗。無法更改默認的重音藍色。
uj5u.com熱心網友回復:
在 macOS 上可以這樣更改:
struct ContentView: View {
init() {
UserDefaults.standard.set(1, forKey: "AppleAccentColor") // << here !!
}
var body: some View {
TabView {
使用 Xcode 13.4 / macOS 12.4 測驗

*參見其他值https://stackoverflow.com/a/51695756/12299030
**還有一些相關的https://stackoverflow.com/a/68846972/12299030
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/497950.html
上一篇:如何在AppDelegate和SceneDelegate之間共享物件
下一篇:am-pm格式的日期選擇器
