SwiftUI 主題強調色

xcode 項目默認會生成一個名爲 “AccentColor” 的變量。可以在 Attributes Inspector 中進行相關設置:

如果不小心刪掉了這個變量,也可手動添加 Color Set:

名稱改爲 “AccentColor” 即可。

此外,在 Build Setting 裏,配置全局的 Accent Color 變量名爲 “AccentColor”

對一個 View 組件,tint 優先級比 accentColor 高,並且後者可能會被覆蓋。

Button("hello") {
    
}
.buttonStyle(.borderedProminent)
.tint(.blue)
.accentColor(.green)

顯示效果:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章