How to add images on a pusbutton
3 次查看(过去 30 天)
显示 更早的评论
Hi everybody!
I'd like to show the action of pressing pushbutton. I explain my problem: I created two images.
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
and
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
The "standard" image is the first one. I'd like to change it with the second one while pressing, just for few seconds, and after to return at the standard one... Is it possible? How can I do it??
There's the possibility to set pushbutton background as transparent??
Thanks!
0 个评论
采纳的回答
Grzegorz Knor
2012-1-30
You can set images in this way:
function test1
i1 = imread('http://img818.imageshack.us/img818/7208/03close.png');
i2 = imread('http://img843.imageshack.us/img843/5276/03closeb.png');
button = uicontrol('style','pushbutton','position',[10 10 55 55],'callback',@b_clbck);
set(button,'cdata',i1)
function b_clbck(src,event)
set(button,'cdata',i2)
pause(2)
set(button,'cdata',i1)
end
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!