Reorder visual stacking of UI components
uistack function is not supported in App Designer or in
apps created using the
uifigure function. Instead, modify the
stacking order of components in a container by setting the
property of the container. For more information, see Change Front-to-Back Component Order.
uistack( shifts the specified
component up one level within the front-to-back visual stacking order of UI components. If
comp is specified as a vector of UI components, each component in the
vector gets shifted up by one.
Reorder Vector of Panels
Create five overlapping panels with different titles and background colors.
f = figure; a = uipanel(f,'Title','A','BackgroundColor','white'); b = uipanel(f,'Title','B','BackgroundColor','cyan'); c = uipanel(f,'Title','C','BackgroundColor','green'); d = uipanel(f,'Title','D','BackgroundColor','yellow'); e = uipanel(f,'Title','E','BackgroundColor','magenta'); a.Position = [0.35 0.50 0.30 0.35]; b.Position = [0.18 0.40 0.30 0.35]; c.Position = [0.08 0.21 0.30 0.35]; d.Position = [0.25 0.33 0.32 0.35]; e.Position = [0.30 0.27 0.30 0.35];
List the order of children in the figure.
figChildren = f.Children
figChildren = 5×1 Panel array: Panel (E) Panel (D) Panel (C) Panel (B) Panel (A)
Reorder the panels by shifting
c up one
level in the stack, relative to their previous positions.
comp = [a c]; uistack(comp);
List the children again. Changing the stacking order of the panels also changes the order of the children in the figure.
figChildren = f.Children
figChildren = 5×1 Panel array: Panel (E) Panel (C) Panel (D) Panel (A) Panel (B)
Reorder Tabs in Tab Group
Create a figure that contains a tab group with five tabs.
f = figure; tg = uitabgroup(f,'Position',[0.05 0.05 0.85 0.85]); t1 = uitab('Title','Survey Questions'); t2 = uitab('Title','Demographic'); t3 = uitab('Title','Participant List'); t4 = uitab('Title','Raw Data'); t5 = uitab('Title','Plot');
Move the Raw Data tab to the bottom of the stack.
Move the Survey Questions tab down two levels.
comp — UI component
single object | vector of objects
UI component to reorder, specified as a single object or vector of objects, such as
objects. Use this argument to specify the UI components you want to reorder within the
comp is specified as a vector of UI components, each
component in the vector must share a parent and the vector must be a subset of the
children of the parent container. For example, if a figure has six child UI components,
comp can have no more than five elements.
moveto — Location
'up' (default) |
Location to move a UI component, specified as one of the values in the following table. Use this argument to specify the stack position you want a UI component to move to.
|Move to Value||Description|
|To the top of the current stack.|
|To the bottom of the current stack.|
step — Number of levels to shift
1 (default) | positive integer
Number of levels to shift a UI component up or down in a stack, specified as a positive integer.
If you specify a step number that is greater than the number of stack levels available to move, then the UI component moves to the top or bottom of the stack. For example, if you have five stack levels and you specify a component to move down six steps, that component moves to the bottom of the stack.
Introduced before R2006a