Skip to Main Content
Learning Swift, 3rd Edition
book

Learning Swift, 3rd Edition

by Jonathon Manning, Paris Buttfield-Addison, Tim Nugent
March 2018
Beginner content levelBeginner
378 pages
8h 45m
English
O'Reilly Media, Inc.
Content preview from Learning Swift, 3rd Edition

Chapter 13. Custom Views and View Controllers

Selfiegram is now themed and looking much nicer than before, but we still haven’t really done much customization beyond some color tweaks and font changes. Let’s take a look at building a custom UIView and UIViewController subclass to further improve our app.

The reason to make a custom view or view controller is to do something that isn’t available in the ones Apple or third-party libraries provide. In our case we are going to be making a replacement for the image picker we are currently using to take photos.

Note

There are reams of third-party camera view controllers out there, each with its own strengths and weaknesses, but we are going to be creating our own. This is both because it is a good example of what it involves and because it lets us talk a bit about working with the camera in iOS, beyond what we could do with the image picker.

We will be using the AVKit framework to handle the communication with, and presentation of, the camera. AVKit is a framework that includes a great deal of classes and functions for interacting with, displaying, and creating audio and video content—hence the name AVKit. Using AVKit you could build yourself an entire video and audio editing suite, but we’re going to start small and just capture images from the camera.

There is a lot to do to this chapter. We will need a custom view to show what the camera is seeing, we are going to need a custom view controller to perform the role of talking to the ...

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.
Start your free trial

You might also like

Learning To Program With Swift

Learning To Program With Swift

T. Rogers

Publisher Resources

ISBN: 9781491987568Errata Page