Created
August 4, 2019 16:17
-
-
Save Dev1an/97b5c515b15ae36f0502cc731ac93f13 to your computer and use it in GitHub Desktop.
SwiftUI clamping bug
This file contains hidden or 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
| ZStack(alignment: .trailing) { | |
| if model.cursor == model.number.count { | |
| HStack { Cursor() } | |
| } | |
| HStack(spacing: 0) { | |
| ForEach(digits, id: \.0) { (offset, character) in | |
| ZStack(alignment: .leading) { | |
| Text(String(character)) | |
| HStack(spacing: 0) { | |
| self.overlay.onTapGesture { self.model.cursor = offset } | |
| self.overlay.onTapGesture { self.model.cursor = offset + 1 } | |
| } | |
| if self.model.cursor == offset { Cursor() } | |
| }// .fixedSize() fixes the bug | |
| } | |
| } | |
| }.fixedSize() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment