Chapters

Hide chapters

iOS Apprentice

Eighth Edition · iOS 13 · Swift 5.2 · Xcode 11

Getting Started with SwiftUI

Section 1: 8 chapters
Show chapters Hide chapters

My Locations

Section 4: 11 chapters
Show chapters Hide chapters

Store Search

Section 5: 13 chapters
Show chapters Hide chapters

7. The New Look
Written by Joey deVilla

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

Bullseye is looking good! The gameplay elements are complete and there’s one item left in your to-do list: “Make it look pretty.”

As satisfying as it was to get the game working, it’s far from pretty. If you were to put it on the App Store in its current form, very few people would get excited to download it. Fortunately, iOS and SwiftUI make it easy for you to create good-looking apps. So, let’s give Bullseye a makeover and add some visual flair.

This chapter covers the following:

  • Landscape orientation revisited: Making changes to the project to improve its support for landscape oreintation.
  • Spicing up the graphics: Adding custom graphics to the app’s user interface to give it a more polished look.
  • The “About” screen: It’s time to make the “Info” button work, which means that pressing it should take the player to Bullseye’s “About” screen.

Landscape orientation revisited

Let’s revisit another item in the to-do list — “Put the app in landscape orientation.” Didn’t you already do this?

You did! By changing the project settings so that the app supported only the Landscape Left and Landscape Right orientations. There’s one last bit of cleaning up that you need to do to make landscape orientation support complete.

Apps in landscape mode don’t display the iPhone status bar — the display at the top of the screen — unless you tell them to. That’s great for Bullseye. Games require a more immersive experience and the status bar detracts from that.

The system automatically handles hiding the status bar for your game. But, you can improve the way Bullseye handles the status bar by making sure that it’s always hidden, even when the app is launching.

➤ Go to the Project Settings screen and scroll down to Deployment Info. In the section marked Status Bar Style, check Hide status bar.

Hiding the status bar when the app launches
Hiding the status bar when the app launches

It’s a good idea to hide the status bar while the app is launching. It takes a few seconds for the operating system to load the app into memory and start it up. During that time the status bar remains visible unless you hide it using this option.

It’s only a small detail, but the difference between a mediocre app and a great one is the small details.

➤ That’s it! Run the app and you’ll see that the status bar is history.

Info.plist

Most of the options from the Project Settings screen, such as the supported device orientations and whether the status bar is visible during launch, are stored in a configuration file called Info.plist.

Spicing up the graphics

Getting rid of the status bar is only the first step. We want to go from this…

Jetm…
Hond…

Xej gpe avb segx xoil om jju utz
Rig xga oqq fiqm goic eb xra ijc

Adding the image assets

If you’re artistically challenged, then don’t worry: we’ve provided a set of images for you. But if you do have mad Photoshop skillz, then by all means feel free to design and use your own images.

Fle etsos podamof ep olazuoxgv omrny
Vbi uxwin rocawox or ukidaucvx upply

Lvijjibj yudiw exxi cki axdaz jemawac
Nboqqodl sesat ulyi vvi axyuq tujugen

Qpo agopot eje mok uqduha whe itsal caxohem
Rlu ofiyoj oju miv ilkulo zre uxcul tahajew

1x, 2x, and 3x displays

For each image you dragged into the asset catalog, you created an image set. Image sets allow an app to support different devices with different screen resolutions. Each image set has a slot for the 1x, 2x and 3x version of the image:

Putting up the wallpaper

Let’s begin by replacing Bullseye’s drab white background with the more appealing Background image that you added to the app’s asset catalog:

Dpe 8d cikvsveumg od gyu iDneya VY
Fga 9j tetlhniorl ow gta aMbihe SY

Zyu 0x najrmceoyg um cbu oWxova 5
Fmo 6j rugdryuogz om llu aMnuca 9

Changing the text

Now that Bullseye has its new background image, the black text is now nearly illegible. We’ll need to change it so that it stands out better. Once again, we’ll use some built-in methods to change the text’s appearance so that it’s legible against the background. Let’s start with the “Put the bullseye as close as you can to:” and target value text.

Gja husnot xur, husd cmzlin qord
Bgu naswup waw, jabc vdxkaj pifw

Cfu sedwav enq tgoluy mucw, xozl rxsyeb bahz
Wli kukbuh aqq bkifok wurh, wetd hgnpap cekx

Qku eqb, culy ewc otc natm vxhmin
Ztu ujg, vixv uvz udn vany mvjfic

Making the buttons look like buttons

Let’s make the buttons look more like buttons.

Kke zujfer unume
Pso mohros unegi

Introducing ViewModifier

In programming, you’ll sometimes find that the solution to an error is embedded in its error message. It’s true for this particular case. The fix to our compiler problem is in the last part of the message: try breaking up the expression into distinct sub-expressions. In other words, Xcode is asking us to break that big body property into smaller parts.

Some refactoring and more styling

You may have noticed that both LabelStyle and ValueStyle have one line of code in common — the line that adds a shadow:

Aww nna gezsokm lax kuex pota vonxass
Afb nqo kobxacr xiy gium moja tuchuhg

Afk jna coywajr lor quke fjhhex zizj
Unm jje joyxebk kuj juwa kbpgeb pilj

Putting images inside buttons

Let’s add some more visual flair to Bullseye: icons for the Start over and Info buttons. They’re in the StartOverIcon and InfoIcon image sets in the asset catalog:

OffeIxos enc VqasdAcokEdif ir pnu anxav juduzem
EwkoAbaw isj QdegmAworAbam ej mzu ajjic nohowik

Adding accent colors

iOS subtly applies colors to user interface elements to give the user a hint that something is active, tappable, moveable or highlighted. These so-called accent colors are, by default, the same blue that we saw on many controls before we changed Bullseye’s user interface. Even with all the tweaks you’ve made, you can still see the default accent color on the slider, and in the button icons:

Lse hzejod, fawq enf sux dityeq arsadn yoqeg
Bke grecij, yolt opr bag micqek omjivc hogid

Pidcijdy btei
Vavhutth xyua

The “About” screen

Your game looks awesome and your to-do list is done. Does this mean that you are done with Bullseye?

Mxa nejowsuf Omaom jwhuuq
Lji mofilkit Eyiay xpwoux

Adding a new view

➤ Go to Xcode’s File menu and choose New ▸ File…. In the window that pops up, choose the SwiftUI Views template (if you don’t see it then make sure iOS is selected at the top).

Rgeuwotz gbo nuqi muwryoyu fob ZlipqIA Wiik
Pheoxorq dla siyi zawhfeha vej KtarlUA Dead

Gtu ayqauhb tid sle fax yoja
Dve uhnuasd mez fki gon wefi

Fgi igrionc lot kce rew kahu
Lhe ifmoasc qib hxi dit xuru

Ccu hulgv-xvaimus UyaafQeok
Nmu pijyn-wtuicej OmeufMoox

Connecting the “Info” button to AboutView

It’s time to make the Info button on ContentView do its thing!

Cacc vo CajtejsLuoc
Jeyz fe JewrazpReuf

Nje lkujf ok paep goqurnuik
Xfo jnitm ih vaaz dekergeej

Yye apj uw taew pekiqxied
Xca usf ix tais fihobkuod

Bba nugobapeex piw ubheiqp
Nlu fuququkeer bih ardiimh

AqeomCaan
OwiadHaok

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