I have an overlay modifier with some Buttons that I'd like to make clickable, but they are not working for some reason. It seems like a simple fix, but moving the offsets to different subviews didn't seem to work.
struct MyView: View {
@State private var textOffset = 300
let users = ["first","second","third","fourth","fifth","sixth","seventh"]
var body: some View {
Color.yellow
.frame(width: 200, height: 20)
.overlay (
HStack {
ForEach(users, id: \.self) { user in
if user == users.first {
Link(user, destination: URL(string: "myelin")!)
} else {
Text("•")
Link(user, destination: URL(string: "mylink2")!)
}
}
}
.fixedSize()
.offset(x: textoffset, y: 0)
)
.animation(.linear(duration: 10)
.repeatForever(autoreverses: false), value: textoffset)
.clipped()
.onAppear {
textoffset = -300.0
}
}
}