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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access