Created
April 11, 2012 20:24
-
-
Save jonalter/2362207 to your computer and use it in GitHub Desktop.
iOS: using a tableView to scroll horizontally like pulse
This file contains hidden or 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 colors = ['red', 'green', 'blue', 'pink', 'brown']; | |
var data = []; | |
var win = Ti.UI.createWindow({ | |
backgroundColor: 'white' | |
}); | |
win.open(); | |
function createRow(params){ | |
var row = Ti.UI.createTableViewRow({ | |
height: 130, | |
title: params.color, | |
selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE | |
}); | |
var view = Ti.UI.createView({ | |
height: 130, | |
width: 130, | |
transform: Ti.UI.create2DMatrix({rotate:90}), | |
backgroundColor: params.color | |
}); | |
var label = Ti.UI.createLabel({ | |
height: 'auto', | |
width: 'auto', | |
backgroundColor: 'black', | |
color: 'white', | |
text: params.color | |
}); | |
view.add(label); | |
row.add(view); | |
view.addEventListener('click', function(){ | |
Ti.API.info('CLICK'); | |
}); | |
return row; | |
} | |
var cl = colors.length; | |
for(var i = 0, l = 25; i<l; i++){ | |
data.push(createRow({ | |
color: colors[i%cl] | |
})); | |
} | |
var holder = Ti.UI.createView({ | |
backgroundColor: 'orange', | |
height: 150, | |
top: 200 | |
}) | |
var tableView = Ti.UI.createTableView({ | |
data: data, | |
top: 140, | |
left: 45, | |
width: 130, | |
height: 1024, | |
anchorPoint: {x:0, y:0}, | |
transform: Ti.UI.create2DMatrix({rotate:-90}), | |
showVerticalScrollIndicator: false, | |
allowsSelection: true, | |
backgroundColor: 'transparent' | |
}); | |
holder.add(tableView); | |
win.add(holder); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment