Recipe: Creating a Custom Input View

A custom input view replaces the keyboard with a view of your design whenever a text view or text field becomes first responder. You can add custom input views to nontext views as well as to text views. Recipe 6-4 focuses on the text scenario.

When you set a responder’s inputView property, the view that is assigned to that property replaces the system keyboard. The easiest way to demonstrate this feature is to create a colored view and assign it to the inputView property. Consider the following code snippet. It creates two text fields. The code assigns the second field’s inputView property to a basic UIView instance that has a purple background:

// Create two standard text fields ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.