Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10474] iOS: Semi-opaque TableViewRow backgroundColor doesn't play nice with title attribute

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-09-14T16:24:10.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sRelease 2.1.3, Release 3.0.0, Sprint 2012-18 API, 2012 Sprint 18
ComponentsiOS
LabelsSupportTeam, api, module_tableviewrow, qe-testadded
ReporterEduardo Gomez
AssigneeBlain Hamon
Created2012-08-16T13:07:16.000+0000
Updated2012-10-26T21:12:21.000+0000

Description

Problem

When applying a semi opaque backgroundColor to a tableViewRow in conjunction with the title attribute, the backgroundColor is not rendered properly.

Actual

The title area of the row is applied the same backgroundColor as the row, resulting in a more opaque background. For example, if the color #50000000 is used, the table row background color is rendered 50% black, however the title area of the row is also rendered with 50% black background, resulting in a 75% black background due to the underlying row color.

Expected

The title area of a row should have no background color rendered to it.

Repro sequence

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
//
var win = Titanium.UI.createWindow({  
    title:'Tab 1',
  
});

var tbl = Ti.UI.createTableView()
win.add(tbl);

var tblData = [];

var row = Ti.UI.createTableViewRow({
	title: 'testing 123',
	backgroundColor: '#50000000'
});

tblData.push(row);
tbl.setData(tblData);

win.open();

Tested on

iOS 5.1 simulator

From the color section in the docs for on Titanium.UI:

"An additional alpha channel is supported as a prefix to the hex triplet. So, to make the purple-like color '#ff00ff' semi-opaque, you could use an alpha value of '55', giving, '#55ff00ff' or '#5f0f'."

Attachments

FileDateSize
iOS Simulator Screen shot Aug 15, 2012 5.14.17 PM.png2012-08-16T13:07:16.000+000017046

Comments

  1. Blain Hamon 2012-08-20

    Note: This is because the native built-in label is also getting the color. We need to reset the label to a fully clear background when the BG color is nonopaque.
  2. Allen Hartwig 2012-08-20

    Blain, what is the scenario where the label needs to inherit any background color? Shouldn't it always be fully clear?
  3. Blain Hamon 2012-08-23

    The scenario is [performance](https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html#//apple_ref/doc/uid/TP40010156-CH14-SW30). Even natively, Apple stresses to avoid using clear (more specifically, opaque views are better) because then the graphics engine doesn't have to do a complex compositing, but can quickly [blit](https://en.wikipedia.org/wiki/Bit_blit) the pixmap onscreen without alphas or masking. a = b is a significantly faster operation than a = (1-x)*a + x*b.
  4. Blain Hamon 2012-08-23

    https://github.com/appcelerator/titanium_mobile/pull/2817
  5. Olga Romero 2012-08-27

    Verified fix with: Titanium Studio, build: 2.1.2.201208201549 Titanium SDK:2.2.0.v20120824175712 Devices: Simulator 5.1 iPhone 4.3.5
  6. Shyam Bhadauria 2012-09-06

    Re-opening to edit label
  7. Blain Hamon 2012-09-06

    Is this going to be re-closed now that the label's edited, or does there remain more work?
  8. Eric Merriman 2012-09-11

    Seem as though this was inadvertently reopened. Closing once again
  9. Vishal Duggal 2012-09-14

    Reopeneing to add merge labels
  10. Satyam Sekhri 2012-09-17

    Verified on: Titanium Studio: 2.1.2.201208301612 Titanium SDK: 2.1.3.v20120915120319 Device: iPad2 (v5.1)

JSON Source