Post

Replies

Boosts

Views

Activity

Reply to SWIFTUI LAYERING ISSUE: BACKGROUND ALWAYS APPEARS IN FRONT OF CONTENT
ZStack(alignment: .leading) { // Hidden text to force view updates when state changes Text("\(noteStateTracker)") .frame(width: 0, height: 0) .opacity(0) // 1. Background rectangle explicitly at the bottom layer RoundedRectangle(cornerRadius: 6) .fill(sceneBackgroundColor(for: scene)) .padding(.horizontal, 4) // 2. Content explicitly on top HStack { Image(systemName: "line.3.horizontal") .foregroundColor(.blue) .frame(width: 20) Text("\(index). \(truncateTitle(scene.title.isEmpty ? "Untitled Scene" : scene.title))") .foregroundColor(selectedScene?.id == scene.id ? .blue : .primary) .fontWeight(selectedScene?.id == scene.id ? .bold : .regular) Spacer() if scene.isComplete { Image(systemName: "checkmark.circle.fill") .foregroundColor(.green) .font(.system(size: 12)) .padding(.trailing, 8) } } .padding(.vertical, 4) .padding(.leading, 30) } .contentShape(Rectangle()) .onTapGesture { selectedChapter = chapter selectedScene = scene } .onDrag { NSItemProvider(object: "\(scene.id.uuidString)|scene" as NSString) } .onDrop(of: ["public.text"], isTargeted: Binding<Bool>( get: { hoveredSceneID == scene.id }, set: { isTargeted in hoveredSceneID = isTargeted ? scene.id : nil } )) { providers in handleSceneDrop(providers, scene, chapter) } .contextMenu { Button("Rename Scene") { sceneToRename = scene newSceneTitleForRename = scene.title newSceneDescriptionForRename = scene.description isRenamingScene = true } Button(role: .destructive) { confirmDeleteScene(scene, chapter) } label: { Label("Delete Scene", systemImage: "trash") } } }
Apr ’25