Reader small image

You're reading from  Building Apple Watch Projects

Product typeBook
Published inFeb 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781785887369
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Stuart Grimshaw
Stuart Grimshaw
author image
Stuart Grimshaw

Stuart Grimshaw has programmed for Apple computers since the days before OS X and has been involved with developing for the Apple Watch since its release. Born in the UK and having lived in Germany and the Netherlands, he is currently a Senior iOS developer in London, England, United Kingdom. He has around 10 years of end-to-end development of projects experience in, iOS, iPadOS, watchOS (Apple Watch), tvOS (AppleTV), and macOS. He is passionate about the potential of the Apple Watch and Apple TV, as well as Apple's Swift programming language, and is a keen proponent of beach coding.
Read more about Stuart Grimshaw

Right arrow

Chapter 8. Images, Animation, and Sound

Now that we have a few functioning apps under our belt, we will take a look at what else there is to do in order to produce a truly release-ready app. One of these topics, the app icon, is mandatory for any project intended for release, while the others are brief explorations of technologies that you are likely to add too many of your own app projects.

The topics covered include:

  • Providing a custom icon to an app

  • Using an Xcode asset catalog

  • Adding an extension to a class

  • Creating the UI layout in code

  • Creating sequential animations

  • Adding audio and video playback to your app

Adding an icon


I don't know about you, but I find that one of the most satisfying points in an app's development is the first time I see its icon appear on the desktop or home screen of whichever platform it runs on. It seems that at that moment the new app is promoted to the status of a real-world application, becoming a member of the exclusive club of useful projects. My hard disk is littered with sketches, try-outs, and projects that for some reason never reached completion and, indeed, my home screens are equally cluttered by the generic app icons added by Xcode to every new project. It's the good ones that get to display their own icon.

So adding an icon is, for me, a sign that an app has progressed far enough that I might be tempted to actually show it to someone.

On the Apple Watch home screen, there is actually a further imperative to add an icon and that is the fact that there are no labels to distinguish one app from another. It's all down to the icon. If you have developed several...

Animation


Way back in Chapter 2, Hello Watch, we used some simple animation to change the background color of the WKInterfaceGroup, which, if you remember, involved calling a method available in WKInterfaceController which takes two arguments, the duration of the animation and a block of code that contains the changes in appearance that should be animated. We saw that even the subtlest of animations can add a sense of "something happening" on the screen, with only a tiny amount of code. Plenty of bang for the buck there.

We are, however, faced with certain limitations of the methods that WatchKit provides us with, one of which is that all the animated changes take place concurrently; it's all at once or not at all. Yet we can easily imagine that even the most modest of animations (we're really not talking Pixar here) might require a series of discrete steps in a particular order. We might want to animate a change in the position of the WKInterfaceGroup and then have it change its background...

Audio and Video


Okay, we've got the visuals, let's make some noise!

It has to be said that audio functionality on the Apple Watch is very limited. It is yet to be seen how the platform develops in this respect, but, as things stand, there is not a great deal you can do with media at the moment beyond simply playing an audio or video file. Perhaps the rationale behind this is that a device that beeps and squeaks at every opportunity is likely to be an irritation not just to the user who is wearing it, but to everybody else in the near vicinity as well. Everything that was said about animation applies to audio tenfold and is probably considered less of a must-have than an if-you-must. And, of course, there is no headphone socket to relieve your family members of this new source of background noise.

However, that said, if we keep an open mind on the subject, we do have an opportunity to explore the extent to which we can use audio on the Apple Watch, and it is likely that there will be a hundred...

Summary


In this chapter, you have learned how to use an Xcode asset catalog to add the required icon images to your watch app and you have used an extension to provide advanced animation functionality to an InterfaceController object beyond that supplied by WatchKit itself. You have learned to lay out the user interface in code as an alternative to using Interface Builder and you have seen how to add media playback to your apps.

Although the techniques presented in this chapter will already elevate your projects to an altogether higher level, giving you opportunities to further engage and delight your users, they are intended as first steps toward a rich and detailed understanding of the wealth of opportunity offered by the Apple Watch. The ways in which we will all be using these features in the not-too-distant future are largely in the hands of you, the developers, whose task it is to explore this wide open field of mobile technology.

In the next chapter, we will look at what needs to be...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Building Apple Watch Projects
Published in: Feb 2016Publisher: PacktISBN-13: 9781785887369
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Stuart Grimshaw

Stuart Grimshaw has programmed for Apple computers since the days before OS X and has been involved with developing for the Apple Watch since its release. Born in the UK and having lived in Germany and the Netherlands, he is currently a Senior iOS developer in London, England, United Kingdom. He has around 10 years of end-to-end development of projects experience in, iOS, iPadOS, watchOS (Apple Watch), tvOS (AppleTV), and macOS. He is passionate about the potential of the Apple Watch and Apple TV, as well as Apple's Swift programming language, and is a keen proponent of beach coding.
Read more about Stuart Grimshaw