Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2099] iOS: leftNavButton image width property is not set

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionWon't Fix
Resolution Date2013-05-08T20:47:53.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterJan Helleman
AssigneeMauro Parra-Miranda
Created2012-10-19T23:54:32.000+0000
Updated2016-03-08T07:41:04.000+0000

Description

SDK 3.0 has the option to use an image in a button. When this button is used as a navigation button it does not respect any settings in width and height. This scales the image in the button to the image it's original width, and the usual height of the navigation bar. Example:
var win1 = Titanium.UI.createWindow();

var win2 = Titanium.UI.createWindow({
    backgroundColor : 'red',
    title : 'Red Window'
});

var navBtn = Ti.UI.createButton({image: '/images/cart.png', width: 16, height: 16});
var btn2 = Ti.UI.createButton({image: '/images/cart.png', width: 16, height: 16});

win2.add(btn2);
win2.leftNavButton = navBtn;

var nav = Titanium.UI.iPhone.createNavigationGroup({
    window : win2
});

win1.add(nav);
win1.open();
"btn" does respect the setting, where as "navBtn" does not... Attached is the icon used for experiment.

Attachments

FileDateSize
cart.png2012-10-19T23:54:33.000+000010744

Comments

  1. Carter Lathrop 2013-05-07

    Jan, The docs point out that the value for leftNavButton must be a view (http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Window-property-leftNavButton). Thus I have made a small example which shows that when leftNavButton is a view, the sizes for the image works as expected.
       var win1 = Titanium.UI.createWindow();
       var win2 = Titanium.UI.createWindow({
           backgroundColor: 'red',
           title: 'Red Window'
       });
       
       var win3 = Titanium.UI.createWindow({
           backgroundColor: 'blue',
           title: 'Blue Window'
       });
       
       var btnView = Ti.UI.createView({
       	backgroundImage: 'cart.png',
       	width: 20,
       	height: 20
       });
       
       btnView.addEventListener('click', function(){
           nav.open(win3, {animated:true});
       });
       
       var nav = Titanium.UI.iPhone.createNavigationGroup({
          window: win2
       });
       
       win2.leftNavButton = btnView;
       win1.add(nav);
       win1.open();
       
    Granted in order to get button-like feel to a custom leftNavButton you would need to custom create the border and on-click highlighting etc. So in terms of functionality, everything is up to date with the current docs. However if you would like to create a new feature request to allow the lefNavButton to include buttons as well as views then by all means create it and be sure to link it in the comments below and I will review and move along to engineering for them to take further action. Thank you for bringing this to our attention, Carter

JSON Source