- 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
4 ビュー (過去 30 日間)
古いコメントを表示
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>
0 件のコメント
回答 (1 件)
Aditya
2024 年 6 月 25 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Develop uifigure-Based Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!