O'Reilly logo

RubyMotion by Clay Allsopp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Static Text with UILabel

Animations are fun, but we also need to display information long enough for the user to actually read it. In most cases, we can use UILabel to display static text. Labels can be very flexible, allowing you to change everything from the font to minute adjustments with the text baseline, and are really easy to get up and running. Let’s add one to our little app.

We’re going to add a UILabel to each box, displaying its index in subviews. We probably wouldn’t ship that sort of feature, but it’s really handy for debugging and might give us a better idea of what’s going on in our animation. UILabel is really lightweight, so it won’t be a pain to add.

Adding labels is going to occur in a new method called add_label_to_box ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required