【问题标题】:TItanium JS: How to add active states to buttons int he header bar for iOSTItanium JS:如何为 iOS 标题栏中的按钮添加活动状态
【发布时间】:2014-10-29 09:23:04
【问题描述】:

我希望使用 Appcelerator Titanium 在 iOS 应用程序的标题栏中向 systemButton 添加活动状态。

我想实现与在 iOS8 中激活列表视图的日历相同的结果。正如您在下面看到的,列表图标处于活动状态,即它具有橙色背景。

有没有办法在应用标题中使用 iOS 系统按钮来实现这一点?

谢谢,欧文

【问题讨论】:

  • 我认为系统按钮无法做到这一点,对于普通按钮,您可以在 onclick 事件中更改颜色。

标签: titanium titanium-mobile appcelerator titanium-alloy appcelerator-mobile


【解决方案1】:

您必须手动跟踪按钮的状态以获得切换效果。这不适用于systemButton

示例:

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;
    }
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-05
    • 1970-01-01
    • 2014-05-14
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多