Post

Replies

Boosts

Views

Activity

Reply to Clipping image prevents button from being tapped
For example struct TestView: View { let url = "https://ts1.cn.mm.bing.net/th/id/R-C.3da9ce39e8e1f19875002d44dcf26244?rik=sYOvBjjpRUOkng&pid=ImgRaw&r=0" @State var touchedIndex: Int = 0 var body: some View { VStack { Text("touched index : \(touchedIndex)") ScrollView(.horizontal) { HStack { ForEach(0..<10) { index in Text("index: \(index)") .onTapGesture { touchedIndex = index } } } .frame(height: 50) } AsyncImage(url: URL(string: url)) { image in image .resizable() .scaledToFill() .frame(width: UIScreen.main.bounds.size.width, height: 200) .clipped() .contentShape(Rectangle()) } placeholder: { ProgressView() } .frame(width: UIScreen.main.bounds.size.width, height: 200) .clipped() .contentShape(Rectangle()) } } } #Preview(body: { TestView() }) The content in ScrollView is clickable but cannot be scrolled horizontally
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’24