zIndex not working on iPhone
Hey guys..
Im curious, anyone know why this wont work?
var win = Titanium.UI.currentWindow;
var views = [];
// title control
var tb4 = Titanium.UI.createTabbedBar({
labels: ['Tables', 'Fixtures'],
index: 0,
style: Titanium.UI.iPhone.SystemButtonStyle.BAR,
width: 180
});
views[0] = Ti.UI.createView({
width: '100%',
height: '100%',
backgroundColor: '#124',
zIndex: 1
});
win.add(views[0]);
views[1] = Ti.UI.createView({
width: '100%',
height: '100%',
backgroundColor: '#624',
zIndex: 0
});
win.add(views[1]);
tb4.addEventListener("click", function(e){
for(var i = 0; i < views.length; i++){
views[i].zIndex = 0;
}
views[e.index].zIndex = 999;
});
win.setTitleControl(tb4);
4 Answers
-
I think it's a bug. I don't know if it's fixed in 1.4.1 or not.
Try to animate the zIndex instead of setting it. Take care to have a zIndex setup to have what to animate from.views[e.index].animate({zIndex:999});
-
Hey guys..
Figured it out. Didnt need zIndex at all, my bad. Code below in case anybody needs it.
var win = Titanium.UI.currentWindow; var views = []; views[0] = Ti.UI.createView({ width: '100%', height: '100%', backgroundColor: '#124', zIndex: 1 }); views[1] = Ti.UI.createView({ width: '100%', height: '100%', backgroundColor: '#000', zIndex: 0 }); // Set a default view. win.add(views[0]); // title control var tb4 = Titanium.UI.createTabbedBar({ labels: ['Tables', 'Fixtures'], index: 0, style: Titanium.UI.iPhone.SystemButtonStyle.BAR, width: 180 }); win.setTitleControl(tb4); tb4.addEventListener("click", function(e){ for(var i = 0; i < views.length; i++){ win.remove(views[i]); } win.add(views[e.index]); });
-
You might try instantiating the view you want on top last, like this:
views[0] = Ti.UI.createView({ width: '100%', height: '100%', backgroundColor: '#124', zIndex: 1 }); views[1] = Ti.UI.createView({ width: '100%', height: '100%', backgroundColor: '#624', zIndex: 0 }); win.add(views[1]); win.add(views[0]);
-
hi,I've tried many times but it still don't work.No matter how I use the method :setZIndex or use the property:ZIndex ,results are always same.