Skip to content

Instantly share code, notes, and snippets.

@Gujci
Created October 15, 2019 08:50
Show Gist options
  • Save Gujci/9154323a1eaf555d718120767ce9ce1d to your computer and use it in GitHub Desktop.
Save Gujci/9154323a1eaf555d718120767ce9ce1d to your computer and use it in GitHub Desktop.
Basic `PageControl` in SwiftUI without any UIKit components.
struct PageControl: View {
var numberOfPages: Int
@Binding var currentPage: Int
var body: some View {
HStack {
ForEach(0..<numberOfPages) { index in
Circle()
.frame(width: 8, height: 8)
.foregroundColor(index == self.currentPage ? .accentColor : .white)
.onTapGesture(perform: { self.currentPage = index })
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment