- Check the Icon Format : Ensure that you are using the correct format for macOS. While .ico files work for Windows, macOS typically uses .icns files for icons. Ensure your .icns file is correctly formatted and not corrupted.
- Set the Icon in the Compiled Application : Make sure you are setting the icon in the correct place in your code. It should be set after the uifigure is created but before it is displayed.
- Use MATLAB's Internal Methods : Sometimes, using MATLAB's internal methods can help. The following code snippet demonstrates how to set the icon for a uifigure on macOS:
macOS compiled application docker icon is not set correctly for uifigure
2 views (last 30 days)
Show older comments
I am using the Application Compiler APPS to build our application on both mac (mac also uses compiler.package.installer)and windows. We now have a mixture of figure and uifigures for the different tools in the application. When the application is compiled, installed, and opened on macOS Ventura the uifigure figures have the matlab icon on the Docker bar instead of our icon (orange with squiggles). Figure based figures do work correctly. I had to implement the following code from this answer to get the uifigure icons correct on the windows computer, but on mac it is still broken. I have tried using both .ico and icns images for the icon, with the same result.
hUIFig = uifigure; % allow this to load first (run it separately from the below code)
% Find the CEF window for the running app's figure: this idea
% comes from DesktopFigureService MALTAB internal class (courtesy)
cefWindowList = matlab.internal.webwindowmanager.instance.windowList;
url = matlab.ui.internal.FigureServices.getFigureURL(hUIFig);
[idx] = arrayfun(@(ww)strcmp(url,ww.URL), cefWindowList);
hWin = cefWindowList(idx);
hWin.Icon = which('your-icon.ico'); % must be ico file
From <https://www.mathworks.com/matlabcentral/answers/499810-how-can-i-change-the-title-bar-icon-of-my-app>
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1609916/image.png)
0 Comments
Answers (1)
Aditya
on 25 Jun 2024
It sounds like you're experiencing an issue with setting the custom icon for uifigure windows in a compiled MATLAB application on macOS. This is a common issue due to the way MATLAB handles uifigure icons differently across platforms. The solution you mentioned works on Windows, but macOS might need a different approach.
hUIFig = uifigure; % Create the uifigure
drawnow; % Ensure the figure is fully initialized
% Find the CEF window for the running app's figure
cefWindowList = matlab.internal.webwindowmanager.instance.windowList;
url = matlab.ui.internal.FigureServices.getFigureURL(hUIFig);
idx = arrayfun(@(ww)strcmp(url, ww.URL), cefWindowList);
hWin = cefWindowList(idx);
% Set the icon (use the correct path to your .icns file)
hWin.Icon = fullfile(pwd, 'your-icon.icns');
0 Comments
See Also
Categories
Find more on Develop uifigure-Based Apps 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!