Within one view hierarchy this can be solved by zIndex
, like
TargetView()
.overlay(
HStack {
if isEditingValue {
Slider(value: $valueToEdit)
.offset(y: 90)
}
}
)
.zIndex(1) // default is 0, so others will be below
//.zIndex(isEditingValue ? 1 : 0) // as variant
// ... other sibling views
if view hierarchy is complex, then view with slider might be overlapped with view from different view hierarchy, and such case cannot be solved just by layout modifiers and needs to be solved at global level of your app UI design.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…