Skip to content

Instantly share code, notes, and snippets.

@Dev1an
Created August 4, 2019 16:17
Show Gist options
  • Select an option

  • Save Dev1an/97b5c515b15ae36f0502cc731ac93f13 to your computer and use it in GitHub Desktop.

Select an option

Save Dev1an/97b5c515b15ae36f0502cc731ac93f13 to your computer and use it in GitHub Desktop.
SwiftUI clamping bug
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