Created
September 30, 2016 10:30
-
-
Save samueleastdev/dffea5870613d7c9e0979f9a846fcbff to your computer and use it in GitHub Desktop.
Appcelerator Ti.UI.ATTRIBUTE_LINK with link color set.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var termsText = L('terms_and_policy', 'No Translation'); | |
if (OS_IOS) { | |
var attr = Ti.UI.createAttributedString({ | |
text : termsText, | |
attributes : [{ | |
type : Ti.UI.ATTRIBUTE_LINK, | |
value : "terms", | |
range : [termsText.indexOf('Terms of Use'), ('Terms of Use').length] | |
}, { | |
type : Ti.UI.ATTRIBUTE_FOREGROUND_COLOR, | |
value : "red", | |
range : [termsText.indexOf('Terms of Use'), ('Terms of Use').length] | |
}, { | |
type : Ti.UI.ATTRIBUTE_UNDERLINE_COLOR, | |
value : "red", | |
range : [termsText.indexOf('Terms of Use'), ('Terms of Use').length] | |
}, { | |
type : Ti.UI.ATTRIBUTE_LINK, | |
value : "policy", | |
range : [termsText.indexOf('Privacy Policy'), ('Privacy Policy').length] | |
}, { | |
type : Ti.UI.ATTRIBUTE_FOREGROUND_COLOR, | |
value : "red", | |
range : [termsText.indexOf('Privacy Policy'), ('Privacy Policy').length] | |
}, { | |
type : Ti.UI.ATTRIBUTE_UNDERLINE_COLOR, | |
value : "red", | |
range : [termsText.indexOf('Privacy Policy'), ('Privacy Policy').length] | |
}] | |
}); | |
$.termsAndConditionsText.attributedString = attr; | |
$.termsAndConditionsText.addEventListener('link', function(_event) { | |
switch (_event.url) { | |
case "terms": | |
console.log("open terms window"); | |
break; | |
case "policy": | |
console.log("open policy window"); | |
break; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment