Post

Replies

Boosts

Views

Activity

Reply to glassBackgroundEffect not appearing in onDrag visionOS
Figured it out. Switched to a List instead of VStack and glass effect appears on drag. struct GlassDragView: View { @State private var items: [String] = ["Item 1", "Item 2"] var body: some View { List { ForEach(items, id: \.self) { item in ZStack { RoundedRectangle(cornerRadius: 8) .foregroundColor(.clear) .frame(width: 200, height: 100) Text(item) .padding() .background(.gray) .cornerRadius(8) } .onDrag { return NSItemProvider(object: item as NSString) } } } .frame(width: 600, height: 400) .background(.gray) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
Reply to glassBackgroundEffect not appearing in onDrag visionOS
Figured it out. Switched to a List instead of VStack and glass effect appears on drag. struct GlassDragView: View { @State private var items: [String] = ["Item 1", "Item 2"] var body: some View { List { ForEach(items, id: \.self) { item in ZStack { RoundedRectangle(cornerRadius: 8) .foregroundColor(.clear) .frame(width: 200, height: 100) Text(item) .padding() .background(.gray) .cornerRadius(8) } .onDrag { return NSItemProvider(object: item as NSString) } } } .frame(width: 600, height: 400) .background(.gray) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24