[TIMOB-1727] button backgroundColor does not work
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2011-04-15T03:00:42.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.7.0, Sprint 2011-14 |
Components | iOS |
Labels | backgroundcolor, button, ios, klist, release-1.7.0 |
Reporter | Robby |
Assignee | Blain Hamon |
Created | 2011-04-15T03:00:39.000+0000 |
Updated | 2017-03-28T20:53:22.000+0000 |
Description
This has been a thorn in the side for many (myself included) for awhile: See http://developer.appcelerator.com/questions/search/button%20backgroundcolor"> http://developer.appcelerator.com/questions/search/button%20backgro...
Here's a testcase to reproduce. It doesn't work both if the button is on the navBar and if it is just in the window. In the window..the color is set on the edges around the button (which is not what 99.9% of people want I'd think :)
var win = Ti.UI.currentWindow;
var btn1 = Titanium.UI.createButton({
title:"Test",
backgroundColor:'#0d8d00',
width:70,
});
win.rightNavButton = btn1;
var btn2 = Titanium.UI.createButton({
title:"Test",
backgroundColor:'#0d8d00',
width:70,
height:120
});
win.add(btn2);
Blain: I'm not sure of the ticket triage procedure at Appcelerator, so I assigned it to you as it is an iphone related bug. If this isn't right, sorry about that. (I just didn't want it to langish around.)
Attachments
File | Date | Size |
---|---|---|
screen-shot-2011-04-04-at-1110.png | 2011-04-15T03:00:39.000+0000 | 122328 |
Oh, one more thing. This was tested with 1.4.0, and with the 9/2/2010 nightly.
And setting backgroundImage: 'none' fixed the main window button, but not the navbar button. In any case, it's a hack. :)
Ticket is still valid. Test in bugtests.
Seriously. How has this not been fixed yet? It still doesn't work in 1.6 or the latest nightly 1.6.1
Bump for this also - rather silly this doesn't just "work" - rather core to the way buttons behave.
Trying to clarify here: do you mean a rounded rectangle button, and how background color defines the corners behind the rounded rectangle, and not the rectangle itself? If so, that actually is Apple's design. Included (And hopefully Lighthouse will actually keep it) is an example outside of Titanium, in Apple's own Interface Builder.
In order to have a custom look to a button, you'll have to use a background image. Take a look at the button example in Kitchen Sink, namely the section that goes
Titanium.UI.createButton({backgroundImage:'../images/BUTT_grn_off.png', backgroundSelectedImage:'../images/BUTT_grn_on.png', backgroundDisabledImage: '../images/BUTT_drk_off.png'})
.With regards to the nav bar, the class behind that (when no custom background image is used) is UIBarButtonItem. As per http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIBarButtonItem_Class/Reference/Reference.html%23//apple_ref/doc/uid/TP40007519"> http://developer.apple.com/library/ios/#documentation/UIKit/Referen... , there's only three styles for a barButtonItem:
Plain: In the nav bar, this is treated as bordered.
Bordered: The background color is determined by the tint of the navbar containing it. This is not editable.
Done: The background color is blue, like a Done button. This color is not editable.
Again, for a custom button style, use a backgroundImage.
Marking as invalid. Blain has explained how to the client can implement custom button UI.
setting Image, color etc.. is very buggy and still not fixed :(
Closing ticket as invalid.