Change Colors of Multiple Objects Efficiently in AppDesigner with Switch
Show older comments
Howdy! I'm currently learning the basics of GUI but I'm familiar with matlab. I made a GUI that I want to have two color schemes that change when a switch is hit (like dark mode/light mode). The switch works and the colors change correctly, but my code seems redundant and I'm currently changing each object's background color and font color one by one so adding or removing objects seems like it would be a lot of work to update down the road. I was wondering if there's an easier way to like group all of the relevant objects together so I could say set all of the button background colors at once in a few lines of code. I defined my colors as variables to at least clean it up a little
A condensed portion of my code right now (but imagine many more objects...):
function BoringGrayColors(app)
% Set object colors to default colors
app.IMPORTDATAButton.BackgroundColor = app.defaultBkg;
app.IMPORTDATAButton.FontColor = app.black;
app.EXPORTPNGButton.BackgroundColor = app.defaultBkg;
app.EXPORTPNGButton.FontColor = app.black;
app.UIFigure.Color = app.defaultBkg;
app.HomeTab.BackgroundColor = app.defaultBkg;
% and many more ...
end
Accepted Answer
More Answers (0)
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
