I'm wondering if someone would be able to point me towards how to properly color text that's typed using a custom keyboard for iOS. Generally the question relates to how the emoji keyboard is able to color words orange when it's selected such that a user can know that said word can be converted to an emoji. I'm writing a custom keyboard where I'd like certain words to be colored when they're typed, and so far have a UIInputViewController
that produces a keyboard that mimics the system keyboard. The UITextDocumentProxy
that one generally uses only accepts Strings
and not AttributedStrings
- meaning it cannot be used to color words. I figure that I need to write my own UIViewController
and connect it to the already written UIInputViewController
such that in iMessage and other apps the system UI would be replaced by one that allows for the words in the message preview to be colored. I'm very new to Swift though and am having a hard time putting it all together.
Would be happy to provide more details as necessary, but generally the goal is to create a custom keyboard where the typing the general iOS example message "Hello from California!" would color Hello red and California blue. Any suggestions on this would be much appreciated!