mirror of
https://github.com/hanzoskill/pagerkit.git
synced 2026-10-30 21:05:53 +00:00
1.9 KiB
1.9 KiB
PKPageControlIndicatorBackgroundStyle
PKPageControlIndicatorBackgroundStyle is an enum that defines the background appearance for the page control indicator in a PKPagesView.
Usage
You apply the background style using the .pkPageControlIndicatorBackgroundStyle(_:) modifier on a PKPagesView.
import SwiftUI
import PagerKit
struct ContentView: View {
var body: some View {
PKPagesView {
PKPage { Text("Page 1") }
PKPage { Text("Page 2") }
}
.pkPageControlIndicatorBackgroundStyle(.prominent)
}
}
Cases
.prominent
Displays a light grey background behind the page control dots. This makes the indicator more prominent.
.minimal
Displays only the page control dots without any background.
.automatic
The behavior of .automatic depends on the platform and user interaction:
- iOS/iPadOS: Shows a background only when the user is dragging the indicator.
- macOS/watchOS/visionOS: Behaves like
.minimal. - tvOS: Behaves like
.prominent.
Platform Differences
The visual representation of each style can vary across different platforms to match the native look and feel.
- On iOS and iPadOS, the
automaticstyle provides a more interactive feel by showing the background only during a drag. - On macOS, watchOS, and visionOS, where the interaction model is different,
automaticdefaults to the cleanerminimallook. - on tvOS,
automaticdefaults toprominentfor better visibility on a television screen.
Best Practices
- Use
.automaticfor most cases: This provides a good default behavior that adapts to each platform's conventions. - Use
.prominentfor better visibility: If the page control is over a complex or visually busy background,.prominentcan improve its readability. - Use
.minimalfor a clean look: If you want a less intrusive page control,.minimalis a good choice.