[TIMOB-10368] iOS: Implement support for custom color/hintTextColor in SearchBar
GitHub Issue | n/a |
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-02-26T23:54:35.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | Release 7.1.0 |
Components | TiAPI |
Labels | api |
Reporter | Davide Cassenti |
Assignee | Hans Knöchel |
Created | 2012-08-09T07:40:07.000+0000 |
Updated | 2019-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
JSON Source
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.
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.
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'
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.
Reopening this ticket based on last comment.
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.
[~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) **
** Test 2 (Search in ListView) **
** Test 3 (Search in TableView) **
FR Passed. Font color for searchbar text and hint text can be set without issue.
Verified changes are included in SDK builds: 7.1.0.v20180227113527 & 7.2.0.v20180228075644
PR to fix this for iOS 13: https://github.com/appcelerator/titanium_mobile/pull/11316 as the hack no longer works.