Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14851] iOS: Label background image doesn't get displayed without giving `height` and `width`

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2013-08-13T17:22:52.000+0000
Affected Version/sRelease 3.1.1
Fix Version/s2013 Sprint 17, 2013 Sprint 17 API
ComponentsiOS
Labelsregression
ReporterMeenakshi Pathak
AssigneeIngo Muschenetz
Created2013-08-13T12:11:55.000+0000
Updated2017-03-03T22:04:18.000+0000

Description

Label background image doesn't get displayed without giving height and width. Here are the steps to reproduce the issue : 1. Create a new Titanium project. 2. Copy and paste the below code to the app.js :
var win = Ti.UI.createWindow({
	backgroundColor : 'white'
});
var label = Ti.UI.createLabel({
		left : 0,
		backgroundImage : 'sample.png'
	});
	
win.add(label);
win.open();
3. Make sure Titanium SDK is set 3.1.1 in tiapp.xml. 4. See the result. Background image is not visible. 5. Now add height and width to the label like:
var label = Ti.UI.createLabel({
		left : 0,
		height:30,
		width:30,
		backgroundImage : 'sample.png'
	});
6. Background image of the label should visible in the tableView row. Note : This behavior is not shown in SDK 2.1.4.

Comments

  1. Sabil Rahim 2013-08-13

    Label by default follows SIZE behavior. That means if you don't specify a width or height the label would assume the size of the text it's supposed contain. In the given test case there is no text, so the computed size would return 0 and that is the expected behavior. If you provide any text to the label(even if it is empty space) the label will show on screen. Refer to http://docs.appcelerator.com/titanium/latest/#!/guide/Transitioning_to_the_New_UI_Layout_System for more information. The fact it worked in 2.1.4, is due to a bug that was not fixed at that point. Marking ticket as invalid.
  2. Lee Morris 2017-03-03

    Closing as invalid.

JSON Source