[英]Swaping the color scheme of tab view indicators in SwiftUI 3
我相信indexViewStyle
目前不可自定義,因為IndexViewStyle
協議不是公開的。
但是,您可以嘗試使用TabView(selection:)
init 和 overlay,或者以某種方式隱藏原始 indexView 並創建自己的。
不知道你所說的配色方案是什么意思。 如果您想更改指示器的顏色或刪除顏色的背景,您可以這樣做:
struct PageView: View {
init() {
UIPageControl.appearance().currentPageIndicatorTintColor = .cyan
UIPageControl.appearance().pageIndicatorTintColor = UIColor.red.withAlphaComponent(1)
UIPageControl.appearance().backgroundStyle = .minimal
}
var body: some View {
TabView {
Text("First")
Text("Second")
Text("Third")
}
.tabViewStyle(.page)
}
}
UIPageControl.appearance().currentPageIndicatorTintColor
改變當前頁面圓點的顏色。 UIPageControl.appearance().pageIndicatorTintColor
改變圓點的rest。 另外,在Swift 14之后,UIPageControl引入了新的樣式。 prominent
的樣式是您現在擁有的圓形視圖和稱為minimal
樣式的舊樣式,我在上面的代碼中更改了UIPageControl.appearance().backgroundStyle
。
我的代碼的output是
如果您想相應地將顏色更改為深色或淺色模式,您可以在您的資源中添加一個color set
並使用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.