Making Text Dynamic with UITextField

Most apps have more than just buttons and labels; usually we need the user to enter some data, like a tweet or email address. UITextField is the basic view we use to grab string-type input, and now we’re going to add one to our little box app. It will let the user pick the UIColor of our boxes using simple commands like “red” and “blue.” Let’s get started.

First we need to add the field to the view hierarchy. UITextField puts many configuration options at our disposal, from fonts to the look of the Return key. We won’t be using all of its properties today, but you can consult Apple’s documentation on the class for more information.[9] Our field should be added in app_delegaterb like so:

Get RubyMotion 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.