Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2178] Black does not work in a background gradient iOS

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:58:19.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M06
ComponentsiOS
Labelsdefect, gradient, ios, iphone, release-1.6.0
Reporterctredway
AssigneeBlain Hamon
Created2011-04-15T03:12:51.000+0000
Updated2011-04-17T01:58:19.000+0000

Description

Running on the iphone, setting a background gradient color to black does not work, Setting it to 000001 does work however.

Code:
var win = Ti.UI.currentWindow;

var view = Titanium.UI.createView({

top:0,
left:0,
//height:height,
//width:width,
backgroundGradient:{
        type:'linear',
        colors:[{color:'#50FFFF',position:0.0},{color:'#000000',position:1.0}]
    }

});

win.add(view);

HD ticket
http://developer.appcelerator.com/helpdesk/view/51211">http://developer.appcelerator.com/helpdesk/view/51211

Comments

  1. Jacob Relkin 2011-04-15

    Apparently the reason why this isn't working is because [UIColor blackColor]'s color space model is kCGColorSpaceModelMonochrome.
    CAGradientLayer does not accept colors that are in the kCGColorSpaceMonochrome color space model.

    The fix for this is to check if the color space is kcGColorSpaceModelMonochrome, and if it is, re-assign the gradient's color to the RGB representation of the color by using UIColor's colorWithRed:green:blue:alpha: method.

    Here's a screenshot of it in action:

    http://cl.ly/3u282l072k3g1O1F1x01">http://cl.ly/3u282l072k3g1O1F1x01

  2. Jeff Haynie 2011-04-15

    (from [e2c1e33e2196f82f790db9282ce9612fd24e2b75]) [#2178 state:fixed-in-qa] [#2837 state:fixed-in-qa] Updating formatting for TiGradient to house style. Actual bug fixes were done by Jacob. See https://github.com/appcelerator/titanium_mobile/pull/58">https://github.com/appcelerator/titanium_mobile/pull/58 https://github.com/appcelerator/titanium_mobile/commit/e2c1e33e2196f82f790db9282ce9612fd24e2b75"> https://github.com/appcelerator/titanium_mobile/commit/e2c1e33e2196...

  3. Ralf Pfeiffer 2011-04-15

    Added test to Integrity, validated fix.

JSON Source