Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Mastering iOS 14 Programming
Mastering iOS 14 Programming

Mastering iOS 14 Programming: Build professional-grade iOS 14 applications with Swift 5.3 and Xcode 12.4 , Fourth Edition

Arrow left icon
Profile Icon Mario Eguiluz Alebicto Profile Icon Chris Barker Profile Icon Donny Wals
Arrow right icon
$12.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7 (15 Ratings)
Paperback Mar 2021 558 pages 4th Edition
eBook
$38.99
Paperback
$54.99
Subscription
Free Trial
Renews at $12.99p/m
Arrow left icon
Profile Icon Mario Eguiluz Alebicto Profile Icon Chris Barker Profile Icon Donny Wals
Arrow right icon
$12.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7 (15 Ratings)
Paperback Mar 2021 558 pages 4th Edition
eBook
$38.99
Paperback
$54.99
Subscription
Free Trial
Renews at $12.99p/m
eBook
$38.99
Paperback
$54.99
Subscription
Free Trial
Renews at $12.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $15.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Mastering iOS 14 Programming

Chapter 2: Working with Dark Mode

We all love it…well most of us do anyway, and those who do have been asking for it for a while now too. Apple first took the plunge into Dark Mode with macOS Mojave back in 2018, not only changing the way users interacted with the OS but also paving the way for developers to build native dark-themed apps for the first time.

Dark mode for iPhone wasn't announced until WWDC 2019, but we all knew it was coming, and with everything that AppKit had offered, we knew we were in for a treat with what UIKit would have to offer.

In this chapter, we'll cover everything you need to know to get up and running with dark mode in iOS and iPadOS; everything from taking an existing app and making the necessary adjustments to support dark mode, to all the little hidden extras that we can add in when building our app to ensure we give the user the best possible experience. We'll also touch on best practices too – taking note of the little...

Technical requirements

For this chapter, you'll need to download Xcode version 11.4 or above from Apple's App Store.

You'll also need to be running the latest version of macOS (Catalina or above). Simply search for Xcode in the App Store and select and download the latest version. Launch Xcode and follow any additional installation instructions that your system may prompt you with. Once Xcode has fully launched, you're ready to go.

Download the sample code from the following GitHub link: https://github.com/PacktPublishing/Mastering-iOS-14-Programming-4th-Edition.

What is Dark Mode?

In this section, we'll start by taking a look at what exactly Dark Mode is, how we can use it, and what it can do not only for the end user but also for developers. We'll cover everything from enabling it on our devices to using environment overrides in Xcode and developer options in the simulator.

Understanding why we would need Dark Mode

As I covered in the introduction of this chapter, most of us have been craving dark mode in iOS for a very long time now. Us developers got our Xcode fix back in 2018 – but one of the burning questions I've been asked many times (especially in the past 12 months) is…why?

It could be down to something as simple as the time of the day. Satellite navigation systems have been doing it in our cars for years – as soon as the sun goes down, our system switches, and a more relaxing, subtle version of our road home pops up on our screen – so why not do that for our apps?

Well, it turns...

Working with views in Dark Mode

So far in this chapter, we've covered not only what dark mode is but also what it has to offer from a development perspective.

In this chapter, we're going to deep dive further into dark mode by looking at how Xcode dynamically handles our UIViews (and objects that are sub-classed from UIViews).

We'll start by understanding the core concept behind adaptive and semantic colors, and by following a simple pattern, Xcode can do so much of the heavy lifting for us.

We'll then dive further and take a look at the various levels of semantic colors available to us, including primary, secondary, and tertiary options, but more importantly, when we would be expected to use them.

What are adaptive colors?

For me, this was a major step in getting developers on board with designing and developing their apps for dark mode and, of course, it was well within Apple's interest to make it as seamless as possible for the developer...

Working with the asset catalog for Dark Mode

Since the ability to add colors to the asset catalog became available back in Xcode 9, there is now even more reason to take full advantage of one of Xcode's prized assets.

In this section, we'll look at how we can use the asset catalog not only to create our custom colors but also to create our own adaptive colors and images, allowing us to harness the power of Xcode when developing dynamic appearance applications.

Using custom adaptive colors

Sticking with our current project, head on over to the file inspector, and highlight the Assets.xcassets folder. With the following layout visible, click on the + button highlighted in the following screenshot and select New Color Set from the list of options:

Figure 2.19 – Creating a color set

Add in another three color sets and name them the following:

  • brandLabel
  • brandSecondaryLabel
  • brandTertiaryLabel

Highlight brandLabel...

Further exploring Dark Mode

In the previous sections, we gave you a lot to think about when either creating or migrating existing apps to Dark Mode under specific circumstances. In this section, we'll take a look at a couple of little "nice to knows" that should always be in the back of your mind when approaching Dark Mode.

Using Dark Mode with SwiftUI

With the announcement of SwiftUI back in June 2019, a massive shift in focus on UI-based development took place. Released at the same time as Dark Mode, and as expected, SwiftUI takes full advantage of switching appearances.

Let's start by taking a look at how we could detect dark mode programmatically in SwiftUI:

  1. First, we'll create an environment variable that allows us to access the current state of the appearance of the device:
    @Environment(\.colorScheme) var appearance
  2. Next, let's use a simple ternary operator to display some text based on the current appearance:
    Text(appearance...

Summary

In this chapter, we've covered a lot about Dark Mode – not only from a programmatic perspective but also the theory behind the appearances and purpose of colors used within our apps.

We started by taking a look at how Xcode and iOS are set up for Dark Mode, learning about the environment overrides used in Xcode, and how we can even switch appearances in our storyboard while developing.

Next, we covered adaptive and semantic colors, and learned not only how these are used with Apple's default system colors but also how we can create dynamic and adaptive color sets ourselves.

Following on from what we learned about color sets, we applied this to images and harnesses the power of the assets catalog.

Finally, we covered some "great to know" topics, such as Dark Mode in SwiftUI, programmatically hailing appearances, and accessibility.

In the next chapter, we'll take a look at lists in iOS 14, covering everything you need to know about...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Explore the world of iOS app development through practical examples
  • Understand core iOS programming concepts such as Core Data, networking, and the Combine framework
  • Extend your iOS apps by adding augmented reality and machine learning capabilities, widgets, App Clips, Dark Mode, and animations

Description

Mastering iOS 14 development isn’t a straightforward task, but this book can help you do just that. With the help of Swift 5.3, you’ll not only learn how to program for iOS 14 but also be able to write efficient, readable, and maintainable Swift code that reflects industry best practices. This updated fourth edition of the iOS 14 book will help you to build apps and get to grips with real-world app development flow. You’ll find detailed background information and practical examples that will help you get hands-on with using iOS 14's new features. The book also contains examples that highlight the language changes in Swift 5.3. As you advance through the chapters, you'll see how to apply Dark Mode to your app, understand lists and tables, and use animations effectively. You’ll then create your code using generics, protocols, and extensions and focus on using Core Data, before progressing to perform network calls and update your storage and UI with the help of sample projects. Toward the end, you'll make your apps smarter using machine learning, streamline the flow of your code with the Combine framework, and amaze users by using Vision framework and ARKit 4.0 features. By the end of this iOS development book, you’ll be able to build apps that harness advanced techniques and make the best use of iOS 14’s features.

Who is this book for?

This book is for developers with some experience in iOS programming who want to enhance their application development skills by unlocking the full potential of the latest iOS version with Swift.

What you will learn

  • Build a professional iOS application using Xcode 12.4 and Swift 5.3
  • Create impressive new widgets for your apps with iOS 14
  • Extend the audience of your app by creating an App Clip
  • Improve the flow of your code with the Combine framework
  • Enhance your app by using Core Location
  • Integrate Core Data to persist information in your app
  • Train and use machine learning models with Core ML
  • Create engaging augmented reality experiences with ARKit 4 and the Vision framework

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 19, 2021
Length: 558 pages
Edition : 4th
Language : English
ISBN-13 : 9781838822842
Vendor :
Apple
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $15.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Mar 19, 2021
Length: 558 pages
Edition : 4th
Language : English
ISBN-13 : 9781838822842
Vendor :
Apple
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$12.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 6,500+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$129.99 billed annually
Feature tick icon Unlimited access to Packt's library of 6,500+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$179.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 6,500+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 151.97
SwiftUI Cookbook
$41.99
Swift Cookbook
$54.99
Mastering iOS 14 Programming
$54.99
Total $ 151.97 Stars icon
Visually different images

Table of Contents

21 Chapters
Chapter 1: What's New in iOS 14? Chevron down icon Chevron up icon
Chapter 2: Working with Dark Mode Chevron down icon Chevron up icon
Chapter 3: Using Lists and Tables Chevron down icon Chevron up icon
Chapter 4: Creating a Detail Page Chevron down icon Chevron up icon
Chapter 5: Immersing Your Users with Animation Chevron down icon Chevron up icon
Chapter 6: Understanding the Swift Type System Chevron down icon Chevron up icon
Chapter 7: Flexible Code with Protocols, Generics, and Extensions Chevron down icon Chevron up icon
Chapter 8: Adding Core Data to Your App Chevron down icon Chevron up icon
Chapter 9: Fetching and Displaying Data from the Network Chevron down icon Chevron up icon
Chapter 10: Making Smarter Apps with Core ML Chevron down icon Chevron up icon
Chapter 11: Adding Media to Your App Chevron down icon Chevron up icon
Chapter 12: Improving Apps with Location Services Chevron down icon Chevron up icon
Chapter 13: Working with the Combine Framework Chevron down icon Chevron up icon
Chapter 14: Creating an App Clip for Your App Chevron down icon Chevron up icon
Chapter 15: Recognition with Vision Framework Chevron down icon Chevron up icon
Chapter 16: Creating Your First Widget Chevron down icon Chevron up icon
Chapter 17: Using Augmented Reality Chevron down icon Chevron up icon
Chapter 18: Creating a macOS app with Catalyst Chevron down icon Chevron up icon
Chapter 19: Ensuring App Quality with Tests Chevron down icon Chevron up icon
Chapter 20: Submitting Your App to the App Store Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7
(15 Ratings)
5 star 93.3%
4 star 0%
3 star 0%
2 star 0%
1 star 6.7%
Filter icon Filter
Top Reviews

Filter reviews by




Jimmy Brown Apr 21, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you want to learn how to program iOS apps correctly and not just some hacked together ToDo app this is the book for you. It explains things simply for you to understand while also going in-depth to make sure you understand the topic. It also has some advanced topics like ARKit and Machine Learning so even experienced iOS Developers have something to learn.It begins by giving an update on iOS 14 and Swift 5.3 with things like WidgetKit, App Clips, user privacy, and Dark Mode. Then it jumps you right in the basis of all app making of using lists and tables. It's over 550 pages of material that you will reference constantly even after you finish the book.The only knock on the book is it doesn’t cover the new features of the language in Swift 5.4. While they are features that are for the more seasoned developer it would have been nice to have in here.From idea to submitting your app to the App Store this book has you covered.
Amazon Verified review Amazon
Nicholas Apr 01, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book kicks off with an update on whats new in iOS 14. Its a good summary to get you up to speed with the latest features like WidgetKit and swift 5.3. I wish there was some info on swift 5.4 in here...Some of the book covers pretty elementary topics like fetching/displaying data from networks in tableviews and having a detail screen give more info, however my favorite chapters in here cover much more interesting topics like: ARKit (augmented reality), WidgetKit, XCTest, and Core ML (machine learning).It's these these more advance topics that really add value to the book and they are why I am rating the book 5 stars. I hope you find the same value in it that I did.
Amazon Verified review Amazon
Juan Catalan Apr 19, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
In order to take full advantage of this book, you will need to be familiar with iOS development with Swift. This is the perfect book if you want to enhance your skills with the latest iOS 14 APIs. If you do not have iOS development experience with Swift, you will not be able to follow the book.The book follows a gradual approach and as you progress thru the chapters, the apps and the code get more complex. The first few chapters walk you thru the APIs needed to build the typical master-detail app. The other chapters introduce more complex APIs such as Core Data, Location Services, Core ML and the Vision framework. The chapters are independent and it’s perfectly fine to skip to the chapter you’re interested in. The code in the book is very accurate and functional. All the code listed in the book is in a GitHub repository. For each chapter in the book, the repository includes starter and completed projects.The authors did a very good job, not only explaining very popular iOS 14 APIs, but also introducing a few chapters with very important concepts in iOS development. Two chapters exclusively dedicated to Swift programming language features: the type system, protocols, generics and extensions. One chapter dedicated to ensuring the app quality with unit tests and UI tests, and the importance of tests when you refactor your app. And the last chapter dedicated to the submission of your app to the App Store with a step-by-step guide.In summary, this book is a complete treaty on iOS development. After reading the book and using the excellent code samples, you’ll be able to master iOS development and submit your apps to the App Store.I am a professional iOS developer with more than 10 years of iOS development experience. I have contributed to more than 30 published apps in the App Store, some of them with millions of users.Disclaimer: I am one of the technical reviewers of this book and during several months I worked with the authors. I tested the sample code, and I verified the accuracy of the code samples.
Amazon Verified review Amazon
Tati Jun 15, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Overall, I’d recommend this book. It’s great to have the first chapter covering the new APIs in iOS 14. The chapters on testing, animations and protocol extensions were great to dive into. The testing chapter also covers mocking and accessibility. Also has a dedicated chapter to Combine, and things like ML & AI if you’re into that. I wish the code-highlighting in the book wasn’t black & white. There are also a handful of references to @IBOutlet throughout the book and it'd have been great to see that replaced. I think it’s a great book for someone who understands iOS development at a working level and is looking for a complete reference to help them solve problems.
Amazon Verified review Amazon
Tom Apr 29, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
It is always to improve your skills as an iOS developer and keep up to date with the latest tech stack, this book certainly helps you do that even if you're a seasoned iOS pro.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.