Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24237] iOS: Add backgroundSelectedColor property (Parity)

GitHub Issuen/a
TypeImprovement
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-01-03T15:39:44.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sRelease 6.1.0
ComponentsiOS
LabelsSDK5.5.0, qe-6.1.0
ReporterPankaj Goyal
AssigneeHans Knöchel
Created2016-12-15T07:05:42.000+0000
Updated2017-01-03T15:40:00.000+0000

Description

Hi, There is no way of setting backgroundSelected Color for ios using Appcelerator. And if i tried to do acheive same by using touchStart and touchEnd Listeners, it sowing some weird behavior. On the tap of left side corner of the device, backgroundSelected color is getting reflected little late. Listeners are getting called, but background color is not changing quickly on iPhone 7 Only. Please help Thanks Pankaj Goyal

Comments

  1. Sharif AbuDarda 2016-12-15

    Hello, Thanks for the ticket. Can you share with how this is handled in native platform? We will consider your request.
  2. Hans Knöchel 2016-12-17

    Feature request accepted, it sounds like a good idea for parity. What we can do is adding the property to buttons, where we natively can control the current state. Since iOS natively doesn't support the property, we use a hack to generate an image from the color set the backgroundSelectedImage property internally. The performance is great and there are no UI glitches. PR: https://github.com/appcelerator/titanium_mobile/pull/8698 Test-case:
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var btn = Ti.UI.createButton({
           title: 'Click me',
           backgroundColor: 'blue',
           backgroundSelectedColor: 'red',
           width: 300,
           height: 40
       });
       
       win.add(btn);
       win.open();
       
  3. Chee Kiat Ng 2016-12-22

    CR and FT passed! PR APPROVED!
  4. Harry Bryant 2017-01-03

    Discovered a minor issue when testing this improvement: when backgroundSelectedColor is present, the tintColor property no longer affects the color of the button's text. Tested On: iPhone 6 Plus 10.2 Device & Simulator Mac OS Sierra (10.12.2) Ti SDK:6.1.0.v20170101113815 Appc Studio: 4.8.0.201611121409 Appc NPM: 4.2.8 App CLI: 6.1.0-319 Xcode 8.2.1 Node v4.4.7
  5. Hans Knöchel 2017-01-03

    No issue here. When setting the backgroundColor, backgroundSelectedColor or backgroundImage property on the button, the UIButtonTypeCustom button type is used internally. Otherwise, using UIButtonTypeSystem (default), the button's background would be half-translucent, which is not usable for the developer. This behavior is there since forever (the last change to that line was in 1.7.0 in 2010). I cleaned this up in [this line](https://github.com/appcelerator/titanium_mobile/pull/8698/files#diff-a555421929ad7fca502ddd144627bdaaR193) but it's still the same behavior.
  6. Harry Bryant 2017-01-03

    Thanks for clarifying, in that case everything is working as intended, closing ticket.

JSON Source