Skip to content

Instantly share code, notes, and snippets.

@yomybaby
Last active March 1, 2016 12:20
Show Gist options
  • Save yomybaby/8234361 to your computer and use it in GitHub Desktop.
Save yomybaby/8234361 to your computer and use it in GitHub Desktop.
iOS7 Colors CommonJS module.Color code from http://codepen.io/ChrisNager/pen/qjbdt I had a test for Titanium Mobile only. But you can use this for any platform supporting hex color code.
// This example require Underscore.js. If Alloy project, do not need required.
// var _ = require('underscore');
var iOS7Colors = require('iOS7Colors');
var win = Ti.UI.createWindow({
backgroundColor : 'white',
layout : 'horizontal'
});
_.each(iOS7Colors,function(value,key){
if(key!=='gradient'){
win.add(Ti.UI.createLabel({
width : 80,
height: 80,
backgroundColor : value,
text : key,
color : 'white',
textAlign : 'center'
}));
}else{
_.each(value,function(colors, gradientName){
win.add(Ti.UI.createLabel({
width : 80,
height: 80,
backgroundGradient: {
type: 'linear',
startPoint: { x: '0%', y: '0%' },
endPoint: { x: '0%', y: '100%' },
colors: colors
},
text : gradientName + '\n gradient',
color : 'white',
textAlign : 'center'
}));
});
}
});
win.open();
module.exports = {
red : '#ff3b30',
orange : '#ff9500',
yellow : '#fc0',
green : '#4cd964',
teal : '#34aadc',
blue : '#007aff',
violet : '#5856d6',
pink : '#ff2d55',
midGray : '#8e8e93',
gray : '#c7c7cc',
gradient : {
red : [ { color: '#ff5e3a', offset: 0.0}, { color: '#ff2a68', offset: 1.0 } ],
orange : [ { color: '#ff9500', offset: 0.0}, { color: '#ff5e3a', offset: 1.0 } ],
yellow : [ { color: '#ffdb4c', offset: 0.0}, { color: '#ffcd02', offset: 1.0 } ],
green : [ { color: '#87fc70', offset: 0.0}, { color: '#0bd318', offset: 1.0 } ],
teal : [ { color: '#52edc7', offset: 0.0}, { color: '#5ac8fb', offset: 1.0 } ],
blue : [ { color: '#1ad6fd', offset: 0.0}, { color: '#1d62f0', offset: 1.0 } ],
violet : [ { color: '#c644fc', offset: 0.0}, { color: '#5856d6', offset: 1.0 } ],
magenta : [ { color: '#ef4db6', offset: 0.0}, { color: '#c643fc', offset: 1.0 } ],
black : [ { color: '#4a4a4a', offset: 0.0}, { color: '#2b2b2b', offset: 1.0 } ],
silver : [ { color: '#dbddde', offset: 0.0}, { color: '#898c90', offset: 1.0 } ],
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment