p = uicontrol('Style', 'pushbutton', 'Position', [100, 150, 100, 30], 'String', 'Pears');
icon = 130*ones([p.Position([4 3]),3], 'uint8');
icon(2:end-1,2:end-1,:) = 240;
icon(end/2+1:end-3,4:end-3,:) = 225;
icon(2,2,:) = icon(1,1,:); icon(1,1,:) = 240;
icon(2,end-1,:) = icon(1,end,:); icon(1,end,:) = 240;
icon(end-1,2,:) = icon(end,1,:); icon(end,1,:) = 240;
icon(end-1,end-1,:) = icon(end,end,:); icon(end,end,:) = 240;
img = imread('pears.png');
icon(6:25, 6:25, :) = imresize(img, [20, 20]);
p.CData = icon;
2 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/529628-how-to-design-gui-buttons#comment_855938
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/529628-how-to-design-gui-buttons#comment_855938
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/529628-how-to-design-gui-buttons#comment_859318
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/529628-how-to-design-gui-buttons#comment_859318
Sign in to comment.