Animation and Groups

As you saw earlier, WKInterfaceController’s animateWithDuration(duration:animations:) method allows you to update properties of your interface objects inside an animation. WKInterfaceGroup is no different, and you can animate all sorts of properties, just like other interface objects. One animation property belongs to groups alone, and that is the content inset. This inset allows you to push content back from the edge of the group, and it can be useful for moving an object around the screen with more control than simple horizontal or vertical alignment.

To illustrate group animations, let’s make a simple watchOS game. Turns out, we can make one to illustrate group animation in about 100 lines of Swift! Our simple “game” ...

Get Developing for Apple Watch, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.