I am trying to create a custom toolbar at the TOP of my iPad app. I'm doing the following and want to use the black opaque style and color for the toolbar. When I run this code, I don't get the "pushed" look when I push on the button with these settings. I can't seem to find the right combination. Anyone?
var mapButton = Titanium.UI.createButton({ title: "Map", width: 50, style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED }) mapButton.addEventListener("click", function() { alert('Click'); }); var helpButton = Titanium.UI.createButton({ title: "Help", width: 50, style:Titanium.UI.iPhone.SystemButtonStyle.BAR }) var toolbar1 = Ti.UI.createToolbar({ top: 0, height: 40, barColor:'black', title:'iMap 5.0', items: [ mapButton, Ti.UI.createButton({systemButton: Ti.UI.iPhone.SystemButton.FIXED_SPACE, width:35 }), helpButton, Ti.UI.createButton({systemButton: Ti.UI.iPhone.SystemButton.FIXED_SPACE, width:190 }), mainTitleLabel, Ti.UI.createButton({systemButton: Ti.UI.iPhone.SystemButton.FLEXIBLE_SPACE}), Ti.UI.createButton({systemButton: Ti.UI.iPhone.SystemButton.ACTION}), Ti.UI.createButton({systemButton: Ti.UI.iPhone.SystemButton.FLEXIBLE_SPACE}) ] }); // end toolbar1 win1.add( toolbar1);
7 Answers
Accepted Answer
Try to set the barcolor to #222. It will make the push effect more visible.
Use a buttonBar instead, wit one label. It will allow you to play with the background color
var mapButton = Titanium.UI.createButton({ labels: ["Map"], backgroundColor:'#a00', style:Titanium.UI.iPhone.SystemButtonStyle.BAR });Is this what u need or I'm understanding wrong ?
I am trying to do a custom bar at the TOP of my app that looks like this: http://www.imap4you.com/images/grab.tiff
Your approach is ok. It seems I don't understand your issue. Try to explain once more.
They are 2 different type of buttons, this is why some are glowing and some not. Remove the style from the map and help button and see if it's what you need.
Dan, BTW, thanks for the patience and help here...I don't want to wear out my welcome with too many newbie questions.
So, when I remove the styles, I get the "glow" effect, but lose the button outline. I need the user to know that it's a button. As a side note, if I set the bar color to blue rather than black I get the "push" effect that I'm looking for; which is strange.
Do you think it would be an easier solution to just use an image view's instead?
Dan, looks like that and setting the SystemButtonStyle to BORDERED does the trick. Here's the code for anyone else trying the same. Thanks DAN!
var mainTitleLabel = Titanium.UI.createLabel({ color:'white', text:'iMap 5.0', textAlign:'center', width:'auto', font: { fontSize:20, fontWeight: 'bold'} });//end mainTitleLabel var mapButton = Titanium.UI.createButton({ title:"Map", width:56, style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED }) var helpButton = Titanium.UI.createButton({ title: "Help", width: 56, style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED }) var settingsButton = Titanium.UI.createButton({ backgroundImage:"gear.png", width:20, height:20, style:Titanium.UI.iPhone.SystemButtonStyle.PLAIN }) //test code var flexSpace = Titanium.UI.createButton({ systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE }); var refreshButton = Titanium.UI.createButton({systemButton:Titanium.UI.iPhone.SystemButton.REFRESH}); var infoButton = Titanium.UI.createButton({systemButton:Titanium.UI.iPhone.SystemButton.INFO_LIGHT}); // Ti.UI.createButton({systemButton: Ti.UI.iPhone.SystemButton.FIXED_SPACE, width:140 }), var toolbar2 = Titanium.UI.createToolbar({ items:[mapButton, flexSpace, helpButton, flexSpace, mainTitleLabel, flexSpace, settingsButton, flexSpace, refreshButton, flexSpace, infoButton ], top:0, borderTop:true, borderBottom:true, // barColor:'#336699' barColor:'#222' }); win1.add(toolbar2);
Your Answer
Think you can help? Login to answer this question!