参考:

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

 

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

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

	<e:RadioButton >
		<e:skinName>
		<e:Skin states="up,down,disabled">
			<e:Image width="100%" height="100%" source="book_scale1_0_png" includeIn="up" />
			<e:Image width="100%" height="100%" source="book_scale1_1_png" includeIn="down" />
			<e:Image width="100%" height="100%" source="book_scale1_2_png" includeIn="disabled" />
			<e:Label />
		</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");

  

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-20
  • 2022-12-23
  • 2021-11-23
  • 2021-12-07
  • 2022-12-23
  • 2022-02-04
  • 2022-01-12
相关资源
相似解决方案