Created
October 15, 2019 08:50
-
-
Save Gujci/9154323a1eaf555d718120767ce9ce1d to your computer and use it in GitHub Desktop.
Basic `PageControl` in SwiftUI without any UIKit components.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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