@@ -133,3 +133,63 @@ examples:
133
133
134
134
win.add(label);
135
135
```
136
+ - title : Links with underline color.
137
+ example : |
138
+ ``` js
139
+ const win = Ti.UI.createWindow({
140
+ backgroundColor: 'gray',
141
+ layout: 'vertical'
142
+ });
143
+ const lbl_a = createLink();
144
+ const lbl_b = createLink();
145
+
146
+ colorLink(lbl_b);
147
+
148
+ win.add([lbl_a, lbl_b]);
149
+ win.open();
150
+
151
+ function createLink() {
152
+ const label = Ti.UI.createLabel({
153
+ top: 20,
154
+ attributedString: Ti.UI.createAttributedString({
155
+ text: 'Check out Titanium SDK',
156
+ attributes: [{
157
+ type: Ti.UI.ATTRIBUTE_LINK,
158
+ value: 'https://titaniumsdk.com',
159
+ range: [10, 12]
160
+ }]
161
+ })
162
+ });
163
+
164
+ label.addEventListener('link', e => {
165
+ Ti.Platform.openURL(e.url);
166
+ });
167
+
168
+ return label;
169
+ }
170
+
171
+ function colorLink(lbl) {
172
+ const attributedString = lbl.attributedString;
173
+ const textColor = 'purple';
174
+ const underlineColor = 'yellow';
175
+
176
+ for (const attribute of attributedString.attributes) {
177
+ if (attribute.type === Ti.UI.ATTRIBUTE_LINK) {
178
+
179
+ // Set new link color.
180
+ attributedString.addAttribute({
181
+ type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
182
+ value: textColor,
183
+ range: attribute.range
184
+ });
185
+
186
+ // Set new underline color.
187
+ attributedString.addAttribute({
188
+ type: Ti.UI.ATTRIBUTE_UNDERLINE_COLOR,
189
+ value: underlineColor,
190
+ range: attribute.range
191
+ });
192
+ }
193
+ }
194
+ }
195
+ ```
0 commit comments