Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the color of the iOS autocorrect suggestion?

After much searching here and on the web and in developer forums, I can't believe that nobody seems to have even asked this question before.

The iOS autocorrect suggestions always popup with a blue font on a white background, regardless of the colors of your UITextField or UITextView or anything else. This looks pretty bad sometimes, e.g. on a dark background. It seems bizarre that it would adopt the font of the text you're editing, but have no way to change the default colors.

And yet in the built-in iOS Notes app, the autocorrect suggestions appear beautifully with a yellow background and red font.

Am I missing something obvious here?

like image 808
sup Avatar asked Aug 29 '12 06:08

sup


1 Answers

The UITextInput protocol defines a method - (NSDictionary *)textStylingAtPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction which the docs claim can be used to style correction rectangles. I gather this would be communicated through a UITextPosition subclass that indicates styling information is being requested, but I'm not sure on the details of that. Something to look more into for sure!

EDIT:

I just implemented a UITextField and a UITextView subclass and overrode the below method. The method was never called :( Sorry to answer with false hope!

EDIT 2: found a blog post explaining why it was never called: http://bjhomer.blogspot.com/2011/11/detecting-backspace-in-uitextfield.html

like image 112
Carl Veazey Avatar answered Oct 20 '22 03:10

Carl Veazey