I would want to present a popup Slider in my iOS app. I'm currently using overlay like so:
.overlay(
HStack {
if isEditingValue {
Slider(value: $valueToEdit)
.offset(y: 90)
}
}
)
The problem is that any content after the view with the .overlay
, will be drawn on top of the slider, that has been moved down with .offset
so as not to obscure the value to be edited.
How can I get the popup Slider to be presented above all other content in correct relation to the view it will edit? I'm currently hiding all content below the value to be edited when the popup Slider is visible, which is not optimal.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.