Skip to Content
Programming iOS 13
book

Programming iOS 13

by Matt Neuburg
December 2019
Beginner
1201 pages
33h 24m
English
O'Reilly Media, Inc.
Content preview from Programming iOS 13

Chapter 10. Text

Drawing text into your app’s interface is one of the most complex and powerful things that iOS does for you. But iOS also shields you from much of that complexity; all you need is some text to draw, and possibly an interface object to draw it for you.

Text to appear in your app’s interface will be an NSString (bridged from Swift String) or an NSAttributedString. NSAttributedString adds text styling to an NSString, including runs of different character styles, along with paragraph-level features such as alignment, line spacing, and margins.

To make your NSString or NSAttributedString appear in the interface, you can hand it to an interface object that knows how to draw it, or you can draw it into a graphics context yourself:

Text-drawing interface objects

Interface objects that know how to draw an NSString or NSAttributedString are:

UILabel

Displays text, possibly consisting of multiple lines; neither scrollable nor editable.

UITextField

Displays a single line of editable text.

UITextView

Displays multiline text; can be scrollable and editable.

Self-drawing text

Both NSString and NSAttributedString have methods for drawing themselves into any graphics context.

Deep under the hood, all text drawing is performed through a low-level technology with a C API called Core Text. At a higher level, iOS provides Text Kit, a middle-level technology lying on top of Core Text. UITextView is largely just a lightweight wrapper around Text Kit, and Text Kit can also ...

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

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

iOS 7 Programming Cookbook

iOS 7 Programming Cookbook

Vandad Nahavandipoor
iOS 9 SDK Development

iOS 9 SDK Development

Chris Adamson, Janie Clayton

Publisher Resources

ISBN: 9781492074601Errata Page