Egret动态设置按钮的图片


参考:

动态设置Button按钮的状态图片

 

按钮有3个状态,up down disabled。这里区别于source,source.down,source.disabled,而是每个状态单独一个image。

且每个单独的<image>标签有一个特别的属性includeIn,这里表示该图片的状态。

	<e:RadioButton id="testBtn" label="" x="398" y="62" anchorOffsetX="0" width="142" anchorOffsetY="0" height="62">
		<e:skinName>
		<e:Skin states="up,down,disabled">
			<e:Image width="100%" height="100%" source="book_scale1_0_png" includeIn="up" id="radio_pic_up"/>
			<e:Image width="100%" height="100%" source="book_scale1_1_png" includeIn="down" id="radio_pic_down"/>
			<e:Image width="100%" height="100%" source="book_scale1_2_png" includeIn="disabled" id="radio_pic_disabled"/>
			<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
		</e:Skin>
		</e:skinName>
	</e:RadioButton>

 

代码中根据图片id获取按钮的图片["radio_pic_up"],再赋值新的texture就可以动态改变按钮的图片了。

this.testBtn["radio_pic_up"].texture = RES.getRes("0_png");
this.testBtn["radio_pic_down"].texture = RES.getRes("1_png");
this.testBtn["radio_pic_disabled"].texture = RES.getRes("2_png");

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM