shrewdbeans
shrewdbeans

Reputation: 12539

TItanium JS: How to add active states to buttons int he header bar for iOS

I'm looking to add an active state to a systemButton in the header bar of an iOS app using Appcelerator Titanium.

I want to achieve the same result as the the Calendar with the list view activated in iOS8. As you can see the below the list icon has an active state, whereby it has an orange background.

enter image description here

Is there a way to achieve this using iOS System Buttons in the header of an app?

Thanks, Owen

Upvotes: 0

Views: 172

Answers (1)

Yozef
Yozef

Reputation: 829

You must manually keep track of the states of the button for a Toggle effect. This does not work with a systemButton.

example:

var button = Ti.UI.createButton({ title: 'Off', isOn: false });
button.addEventListener('click', function(e) {
    if (e.source.isOn) {
        e.source.title = 'Off';
        e.source.isOn = false;
    } else {
        e.source.title = 'On';
        e.source.isOn = true;
    }
});

Upvotes: 1

Related Questions