我尝试在点击后更改LeftNavButton的背景图像,但没有任何反应。当我使用普通按钮执行此操作时,图像将会改变。这样做是否有一些限制,还是有其他方法可以做到这一点?
INDEX.XML:
<Alloy>
<NavigationWindow id="win1" platform="ios">
<Window id="win2" title="Window">
<LeftNavButton>
<Button id="navButtonFilter" class="navButtonFilter" onClick="doClick" platform="ios" autoStyle="true">XX</Button>
</LeftNavButton>
<Button id="button" class="navButtonFilter" onClick="doClick"> </Button>
</Window>
</NavigationWindow>
</Alloy>
index.js:
function doClick(event) {
Ti.API.info('doClick');
$.addClass($.navButtonFilter, 'navButtonFilterActive');
$.addClass($.button, 'navButtonFilterActive');
}
$.win1.open();
index.tss:
"#win1": {
backgroundColor:"white"
}
".navButtonFilter": {
backgroundImage : "/filter.png",
}
".navButtonFilterActive": {
backgroundImage : "/list.png",
}