Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created December 3, 2013 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanleard/7778819 to your computer and use it in GitHub Desktop.
Save alanleard/7778819 to your computer and use it in GitHub Desktop.
Font Size Manipulation
var args = arguments[0] || {};
var changeFontSize = null;
$.sectionTitle.text = args.title;
function setTitles(callback){
if(args.criteria) {
var cLength = args.criteria.length;
for(var i=0; i<cLength; i++){
var title = Ti.UI.createLabel({
text:" "+args.criteria[i].title+" ",
left:((590/(cLength))*(i)),
color:Alloy.Globals.Data.Colors.one,
font:{fontFamily:Alloy.Globals.Data.Fonts.primary, fontSize:16, fontWeight:"bold"},
width:(590/cLength),
textAlign:"center",
height:Ti.UI.FILL,
ellipsize:true,
verticalAlign:Ti.UI.TEXT_VERTICAL_ALIGNMENT_CENTER
});
$.criteria.add(title);
if(title.text == " Not Applicable "){
title.text = " N/A ";
}
if(title.width*.07<title.text.length){
changeFontSize = true;
}
if(i == (cLength-1)){
callback();
}
}
}
}
setTitles(function(){
if(changeFontSize){
for(var i in $.criteria.children){
if($.criteria.children[i]){
$.criteria.children[i].font = {fontFamily:Alloy.Globals.Data.Fonts.primary, fontSize:14, fontWeight:"bold"};
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment