String 无法更改属性字符串的文本颜色

String 无法更改属性字符串的文本颜色,string,appcelerator,String,Appcelerator,var attr=Titanium.UI.createAttributeString({ 文本:值 attributes: [{ type: Ti.UI.ATTRIBUTE_LINK, range: [0, value.length], value: Titanium.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE, },

var attr=Titanium.UI.createAttributeString({ 文本:值

        attributes: [{
                type: Ti.UI.ATTRIBUTE_LINK,
                range: [0, value.length],
                value: Titanium.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
            },
            {
                type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
                value: '#CD1625',
                range: [0, value.length],
            },
            {
                type: Ti.UI.ATTRIBUTE_UNDERLINE_COLOR,
                value: '#CD1625',
                range: [0, value.length],
            }
        ]


    });

    credDetailsValue = Ti.UI.createLabel({
        attributedString: attr,
        width: "70%"
    });

无法更改文本下划线的颜色正在工作

属性下划线颜色
仅在iOS上可用(请参阅文档),并且
属性前景颜色
的工作方式如下:

var win = Ti.UI.createWindow({
    backgroundColor: 'white'
});
var value = "this is a text this is a text this is a text";

var attr = Titanium.UI.createAttributedString({
    text: value,

    attributes: [{
        type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
        value: '#CD1625',
        range: [0, 5],
    }, {
        type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
        value: '#00ff00',
        range: [5, 10],
    }, {
        type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
        value: '#0000ff',
        range: [10, 15],
    }]
});

var lbl = Ti.UI.createLabel({
    attributedString: attr,
    width: "70%"
});
win.add(lbl);
win.open();