NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

DAY 44

Project 9, part 2

Today we’re going to be continuing our look at SwiftUI’s drawing systems by getting a little creative – I think you’ll be surprised how easy it is to make something entrancing just by combining most of what you know with a couple of new techniques.

Today you’re also going to meet the drawingGroup() modifier, which lets us combine view rendering together into a single pass powered by Apple’s high-performance graphics API, Metal. Lots of people have asked me in the past whether I plan to write a book on Metal, and the answer is a definitive no – not only is there a very good one already, but it’s also remarkably hard to get anything good out of the APIs.

That isn’t because Metal is bad – trust me, it’s incredible! – but instead because Apple’s finest engineers have worked hard to make SwiftUI as efficient as possible when working with Metal, and, bluntly, it is extremely unlikely that I can do a better job.

As you’ll find, switching Metal isn’t something you’ll need often, even though it is easy to do. Famous software developer Kent Beck once said our process should be “make it work, make it right, make it fast”, and he’s quite correct. But if you find your drawing works fast without switching to Metal it’s usually best left as-is.

Anyway, enough chat – I said we’d make something entrancing, so let’s get to it!

Today you have three topics to work through, in which you’ll learn about CGAffineTransform, ImagePaint, drawingGroup(), and more.

Need help? Tweet me @twostraws!


Hacking with Swift is sponsored by Instabug

SPONSORED Catch bugs as soon as they happen and know exactly why a crash occurred. Instabug's SDK grabs all the logs they need to fix bugs, crashes and performance issues in minutes instead of days. Get screenshots, device details, network logs, repro steps, and tons of other critical insights needed to resolve issues and prioritize product backlogs straight from your dashboard. It only takes a minute to integrate!

Get started now

Sponsor Hacking with Swift and reach the world's largest Swift community!

100 Days of SwiftUI

The 100 Days of SwiftUI is a free collection of videos, tutorials, tests, and more to help you learn SwiftUI faster. Click here to learn more, or watch the video below.

Back to 100 Days of SwiftUI

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.