xcode 項目默認會生成一個名爲 “AccentColor” 的變量。可以在 Attributes Inspector 中進行相關設置:
如果不小心刪掉了這個變量,也可手動添加 Color Set:
名稱改爲 “AccentColor” 即可。
此外,在 Build Setting 裏,配置全局的 Accent Color 變量名爲 “AccentColor”
對一個 View 組件,tint 優先級比 accentColor 高,並且後者可能會被覆蓋。
Button("hello") {
}
.buttonStyle(.borderedProminent)
.tint(.blue)
.accentColor(.green)
顯示效果: