Declaration
compose().zIndex(value: number)nonisolated func zIndex(_ value: Double) -> some ViewParameters
value*numberA relative front-to-back ordering for this view; the default is
0.
Discussion
Use zIndex(_:) when you want to control the front-to-back ordering of
views.
In this example there are two overlapping rotated rectangles. The frontmost is represented by the larger index value.
VStack {
Rectangle()
.fill(Color.yellow)
.frame(width: 100, height: 100, alignment: .center)
.zIndex(1) // Top layer.
Rectangle()
.fill(Color.red)
.frame(width: 100, height: 100, alignment: .center)
.rotationEffect(.degrees(45))
// Here a zIndex of 0 is the default making
// this the bottom layer.
}See also
More in Appearance.
- backgroundSets the view's background to a style.
- badgeGenerates a badge for the view from a localized string resource.
- badgeProminenceSpecifies the prominence of badges created by this view.
- borderAdds a border to this view with the specified style and width.
- buttonSizingThe preferred sizing behavior of buttons in the view hierarchy.
- containerBackgroundSets the container background of the enclosing container using a view.
- headerProminenceSets the header prominence for this view.
- hiddenHides this view unconditionally.
- imageScaleScales images within the view according to one of the relative sizes available including small, medium, and large images sizes.
- labelIconToTitleSpacingSet the spacing between the icon and title in labels.
- labelReservedIconWidthSet the width reserved for icons in labels.
- labelsHiddenHides the labels of any controls contained within this view.