Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10368] iOS: Implement support for custom color/hintTextColor in SearchBar

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2018-02-26T23:54:35.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sRelease 7.1.0
ComponentsTiAPI
Labelsapi
ReporterDavide Cassenti
AssigneeHans Knöchel
Created2012-08-09T07:40:07.000+0000
Updated2019-11-06T13:44:44.000+0000

Description

Feature description

The Titanium.UI.SearchBar object does not allow to change the font color for the text, nor for the hintText. This should be implemented as a new feature on iOS and Android.

Comments

  1. Blain Hamon 2012-08-23

    It is highly unlikely this will be implemented anytime soon. Apple provides [no way to adjust the hint text](https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UISearchBar_Class/Reference/Reference.html), and the [text color property](https://developer.apple.com/library/ios/#documentation/UIKit/Reference/NSString_UIKit_Additions/Reference/Reference.html#//apple_ref/doc/uid/TP40006893) is only available in iOS 5 or later.
  2. Blain Hamon 2012-08-23

    Marking as hold as half the feature can not be implemented (no native means) and the other half would not work on iOS 4.X.
  3. Joe Falcone 2012-10-12

    With Android 4.04 (and possibly other versions of Android 4) and SDK 2.1.3 (I haven't tested with others, but probably the same) this problem is now a real customer problem as the searchBar fontColor is now stuck on 'white' which got me some bug reports from customers who said that they typed stuff into searchBar's and it didn't show up. I confirmed this by changing the backgroundColor of my searchBar's to gray and sure enough the fontColor of the searchBar's are 'white'
  4. Daniel Kunzler 2015-01-05

    I suggest reopening this issue as this feature is present on iOS 5+ and there's still no visible/documented procedure to change SearchBar text color.
  5. Neeraj Gupta 2015-01-07

    Reopening this ticket based on last comment.
  6. Hans Knöchel 2018-01-25

    This is still not natively possible in iOS (checked with iOS 11.2 and Xcode 9). There are workarounds using private API's for this, but this should not be done inside the official Titanium SDK as applications using private API's may be rejected during review. *EDIT*: I found a workaround that does not use private API's directly.
  7. Hans Knöchel 2018-01-26

    [~emerriman] Here you go PR (master): https://github.com/appcelerator/titanium_mobile/pull/9772 PR (7_1_X): https://github.com/appcelerator/titanium_mobile/pull/9844 ** Test 1 (Standalone) **
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var searchBar = Ti.UI.createSearchBar({
         color: 'green',
         hintText: 'Enter value ...',
         hintTextColor: 'red'
       });
       
       win.add(searchBar);
       win.open();
       
    ** Test 2 (Search in ListView) **
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var searchBar = Ti.UI.createSearchBar({
         color: 'green',
         hintText: 'Enter value ...',
         hintTextColor: 'red'
       });
       
       var list = Ti.UI.createListView({
         searchView: searchBar
       });
       
       win.add(list);
       win.open();
       
    ** Test 3 (Search in TableView) **
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var searchBar = Ti.UI.createSearchBar({
         color: 'green',
         hintText: 'Enter value ...',
         hintTextColor: 'red'
       });
       
       var list = Ti.UI.createTableView({
         search: searchBar
       });
       
       win.add(list);
       win.open();
       
  8. Eric Wieber 2018-02-26

    FR Passed. Font color for searchbar text and hint text can be set without issue.
  9. Eric Wieber 2018-02-28

    Verified changes are included in SDK builds: 7.1.0.v20180227113527 & 7.2.0.v20180228075644
  10. David Bankier 2019-11-06

    PR to fix this for iOS 13: https://github.com/appcelerator/titanium_mobile/pull/11316 as the hack no longer works.

JSON Source