Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

iOS AttributedString with ATTRIBUTE_LINK and ATTRIBUTE_FOREGROUND_COLOR together

$
0
0

Hi, I need to use AttributedString and need to make part of label text as link. I am able to use both ATTRIBUTE_LINK and ATTRIBUTE_FOREGROUND_COLOR independently but if I use them both together, the ATTRIBUTE_FOREGROUND_COLOR does not work. However, if I use ATTRIBUTE_BACKGROUND_COLOR with ATTRIBUTE_LINK, it does work.

What I want to to make url as LINK and need to change default dark blue colour to something as per my app theme. Below is code,

attributes = [];
        var text = "my site is http://google.com"    
 
        //Link
        attributes.push({
                type: Titanium.UI.iOS.ATTRIBUTE_LINK,
                value: matchTextArray[i],
                range: [11, text.length]
            });
 
        //color
        attributes.push({
            type: Titanium.UI.iOS.ATTRIBUTE_FOREGROUND_COLOR,
            value: '#01B0F1',
            range: [11, text.length]
        });
 
        var formater = Titanium.UI.iOS.createAttributedString({text: $.label.text, attributes: attributes});
        $.label.attributedString = formater;
In above code, the ATTRIBUTE_FOREGROUND_COLOR does not get reflected, however if I comment the ATTRIBUTE_LINK, the ATTRIBUTE_FOREGROUND_COLOR does work.

One more query, is there any way, I can make this link to work on click event, currently it only work with link event which is called when you hold URL for sometime.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>