Matlab GUI 界面编程:添加按钮背景图片
1.新建按钮,
2.在界面m文件中,找到界面的OpeningFcn函数
% --- Executes just before day1 is made visible.
function day1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to day1 (see VARARGIN)
a = imread('load2.png'); %读取图片
set(handles. pushbutton2,'CData',a);%设置显示位置
% Choose default command line output for day1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
本文链接:https://blog.csdn.net/qq_26126831/article/details/103420093