Chapters

Hide chapters

iOS Apprentice

Eighth Edition · iOS 13 · Swift 5.2 · Xcode 11

Before You Begin

Section 0: 3 chapters
Show chapters Hide chapters

Checklists

Section 2: 12 chapters
Show chapters Hide chapters

My Locations

Section 3: 11 chapters
Show chapters Hide chapters

Store Search

Section 4: 12 chapters
Show chapters Hide chapters

26. Adding Polish
Written by Eli Ganim

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Your Tag Location-screen is now functional, but it looks a little basic and could do with some polish. It’s the small details that will make your apps a delight to use and stand out from the competition.

In this chapter, you will learn the following:

  • How to improve the user experience by adding tiny tweaks to your app which gives it some polish.
  • How to add a HUD (Heads Up Display) to your app to provide a quick, animated status update.
  • How to continue the navigation flow after displaying the HUD.

Improving the user experience

Take a look at the design of the cell with the Description text view:

There is a margin between the text view and the cell border
There is a margin between the text view and the cell border

There is a margin between the text view and the cell border. However, because the background of both the cell and the text view are white, the user cannot see where the text view begins or ends.

It is possible to tap on the cell but just outside the text view area. That is annoying when you want to start typing: You think that you’re tapping in the text view, but the keyboard doesn’t appear.

There is no feedback to the user that they’re actually tapping outside the text view and they will think your app is broken. In my opinion, deservedly so.

Keyboard activation for cells

You’ll have to make the app a little more forgiving. When the user taps anywhere inside that first cell, the text view should activate, even if the tap wasn’t on the text view itself.

Deactivating the keyboard

It would be nice if the keyboard disappeared after you tapped anywhere else on the screen. As it happens, that is not so hard to implement.

Gmi “Wolsigb uj jpej” adquiz yok wja fonpiuts
Pza “Vuzlusd or flab” ilxeox boc rpo todjiawm

The HUD

There is one more improvement to make to this screen, just to add a little spice. When you tap the Done button to close the screen, the app will show a quick animation to let you know it successfully saved the location:

Guxefe noa bjuce gyu ycgiob uf bsawz al iwacayop frutgquzx
Kalepi dee xzupo nve jzvaol oh fwowf iy onavafip rdaxfbozg

Creating the HUD view

➤ Add a new file to the project using the Swift File template. Name it HudView.

Using the HUD view

Let’s add the code to call this funky new HUD so that you can see it in action.

Whu CUW veur gexefn lwi dmuzu dgyoam
Tme BIY ciuy nuxuyb hba qdoma snsion

Phu REG xuum zaes saj cunig tqi mikaruwaiy vop
Ztu ZEK zoiw cued tun hapiv hta melihifaac xef

Drawing the HUD view

➤ Remove the backgroundColor line from the hud(inView:animated:) method.

Mca RUF toaq get a gufcoeyfs xpopqgecolr qesbchuatb
Phu QIX qiih cij e dopgoapvd bbimgwugazm mivnkvuejn

Displaying the HUD checkmark

➤ The Resources folder for the book has two files in the Hud Images folder: Checkmark@2x.png and Checkmark@3x.png. Add these files to the asset catalog, Assets.xcassets.

Vka GUF yuug xudp vca vnibfgejm inexe
Mhe SIM yiav jovx lqa vvembwoqq enava

Failable initializers

To create the UIImage, you used if let to unwrap the resulting object. That’s because UIImage(named:) is a failable initializer.

Displaying the HUD text

Usually, to display text in your own view, you’d add a UILabel object as a subview and let UILabel do all of the hard work. However, for a view as simple as this, you can also do your own text drawing.

Lna FAS leek zadz vke fraqmxamc afd gja tojq
Kge KUS kuet yopg sxa xrewdsocm ivv yga nujb

Adding some animation

You’ve already seen a bit about animations before — they’re really easy to add.

Improving the animation

You can actually do one better. iOS has something called “spring” animations, which bounce up and down and are much more visually interesting than the plain old version of animations. Using them is very simple.

Handling the navigation

Back to LocationDetailsViewController. You still need to close the screen when the user taps Done.

Cleaning up the code

GCD code can be a bit messy. So let’s clean up the code and make it easier to understand.

Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.
© 2026 Kodeco Inc.

You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now