Search code examples
iosapp-storeuisearchbarappstore-approval

Is customising UISearchField is private


I need to customise UISearchBar:

  • Change search text color
  • Change favicon

There is no API provided by Apple. However, this is one of possible solution:

for(UIView *subView in _searchBar.subviews){
    if([subView isKindOfClass:UITextField.class]){
        UITextField *searchField = (UITextField*)subView;
        searchField.textColor = [UIColor darkGrayColor];
        UIImage *image = [UIImage imageNamed: @"loop.png"];
        UIImageView *iView = [[UIImageView alloc] initWithImage:image];
        searchField.leftView = iView;
    }
}

It works perfectly. But I worry that Apple may reject the app. I know this is not a private API, but also this is not fully public.

Does any one have app in App Store with such kind of code?


Solution

  • You are not calling any private API, so I'm almost sure that this code will pass the AppStore validation. Take note that your code is not future proof, it is possible that Apple will change the inner UISearchBar implementation and your code might stop working. The most reliable solution would be to subclass UITextField and roll out your own code.

    Having said that, it is highly unlikely that this will become a problem, and it's a safe bet that your code will work.