What’s new in SwiftUI for iOS 17

Raw Text

Forums

Learn Start Here Latest Articles What's new in Swift? 100 Days of SwiftUI 100 Days of Swift Swift Knowledge Base SwiftUI by Example Swift in Sixty Seconds Hacking with Swift YouTube videos Swift Playgrounds Get the iOS App

Careers Start Here Interview Questions Interactive Review Test your Swift Find a Job

Store Subscribe to Hacking with Swift+ Browse Swift Courses Book bundles Frequently Asked Questions Lifetime Update Policy Frequent Flyer Club Buy on Apple Books Reader Reviews Refund Policy

About About Hacking with Swift Swift Community Awards Hacking with Swift Live Conference Talks Affiliate Program Newsletter Sponsor the site

SUBSCRIBE

WWDC23 SALE: Save 50% on all my Swift books and bundles! >>

This is another huge year of updates, delivering many highly requested features such as advanced scroll view effects, container relative sizing, and even Metal shaders.

Paul Hudson    June 16th 2023    @twostraws

SwiftUI continues to evolve at a rapid pace, and this year has seen a huge number of improvements to scroll views, fun new SF Symbols effects, advanced support for Metal shaders, and more.

Some of these are things I’ve asked for personally, including the ability to add Metal shaders, making Color work better with Codable , adding a completion closure for animations, allowing us to animate gradients, and being able to selectively round corners of a rectangle – I’ve closed at least a dozen feedbacks just from beta 1!

SAVE 50% To celebrate WWDC23, all our books and bundles are half price , so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Scroll view improvements

How to make a ScrollView snap with paging or between child views

How to disable ScrollView clipping so contents overflow

How to make a ScrollView start at the bottom

How to indent the content or scroll indicators in a ScrollView

How to make views scroll with a custom transition

How to flash the scroll bar indicators of a ScrollView or List

How to enable vertical page scrolling

Drawing and animation improvements

How to add Metal shaders to SwiftUI views using layer effects

How to dynamically adjust the appearance of a view based on its size and location

How to animate SF Symbols

How to run a completion callback when an animation finishes

How to create multi-step animations using phase animators

How to combine shapes to create new shapes

How to adjust the size of a view relative to its container

More welcome improvements

How to add in-app purchases in SwiftUI

How to add an inspector to any view

How to detect and respond to key press events

How to control which NavigationSplitView column is shown in compact layouts

How to add haptic effects using sensory feedback

How to tell the user that no content is available

How to read the red, green, and blue values from a Color

How to make buttons that repeat their action when pressed

And there’s more…

You might expect me to talk about SwiftData here, but I’m not – or at least not yet . Yes, it’s important, and yes it’s genuinely a huge step forward for all iOS developers, but I’m spending a lot of time writing test projects, experimenting, and getting answers to my questions, because I want to be really sure I understand it thoroughly before I write about it.

However, there are other interesting SwiftUI changes to discuss:

There’s improved API for filling and stroking shapes at the same time .

The onChange() modifier now accepts 0 or 2 parameters, and can also be triggered by your initial value

The foregroundColor() modifier has been formally deprecated in favor of foregroundStyle() .

Changing colors in a gradient will animate in iOS 17 and later.

SwiftUI’s default animation is now a spring, there are many more built-in animations such as .bouncy and .snappy , and springs are now created with much simpler API .

There’s new support for rounding some corners of a rectangle but not others.

There’s newer, simpler syntax for making fill shapes and clip shapes: .rect , .capsule , and so on.

When creating table views, we can now write ForEach(users) rather than ForEach(users, content: TableRow.init)

And although it’s more of an Xcode improvement than a SwiftUI improvement, all images and colors defined in assets catalogs now have static names we can use in code rather than strings: Image(.dog) rather than Image("dog") , for example.

There are also new APIs for performing keyframe animations, new map controls, and more – I’m still digging in, writing code samples, and finding techniques that work well.

I particularly like some of the approaches taken in these new APIs, particularly the way things like scroll bar flashing, sensory feedback, and phase animations can be triggered using a simple Equatable comparison – it really lowers the complexity bar

So what about SwiftData?

The dramatic and wide-ranging changes to data management in SwiftUI are really welcome. In fact, there’s a video of me actually letting out a scream during Apple’s State of the Union session at Apple Park – I’m really glad to see it arrive.

However, it’s also something that takes care to get right. I’ll be updating my books for it – of course! – but I also want to make sure I understand the best practices for using it thoughtfully, so I hope you don’t mind a little delay while I’m conducting all my research.

Thank you for your patience!

SAVE 50% To celebrate WWDC23, all our books and bundles are half price , so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

More articles

RSS feed

I screwed up one key accessibility behavior, and now I'm on a mission to do better

Hacking with Swift Live 2023

What’s new in Swift 5.9?

Now available to pre-order: Swift Against Humanity

What's new in Swift 5.8

SwiftUI by Example: Now updated for iOS 16

WWDC22: Wrap up and recommended talks

How to use inner shadows to simulate depth with SwiftUI and Core Motion

Was this page useful? Let us know!

Average rating: 4.6/5

Thank you!

Click here to visit the Hacking with Swift store >>

@twostraws

paul@hackingwithswift.com

Sponsor the site

About             Glossary             Privacy Policy             Refund Policy             Update Policy             Code of Conduct

Swift, SwiftUI, the Swift logo, Swift Playgrounds, Xcode, Instruments, Cocoa Touch, Touch ID, AirDrop, iBeacon, iPhone, iPad, Safari, App Store, watchOS, tvOS, Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries. Pulp Fiction is copyright © 1994 Miramax Films. Hacking with Swift is ©2023 Hudson Heavy Industries.

You are not logged in

Log in or create account

Link copied to your pasteboard.

Single Line Text

Forums. Learn Start Here Latest Articles What's new in Swift? 100 Days of SwiftUI 100 Days of Swift Swift Knowledge Base SwiftUI by Example Swift in Sixty Seconds Hacking with Swift YouTube videos Swift Playgrounds Get the iOS App. Careers Start Here Interview Questions Interactive Review Test your Swift Find a Job. Store Subscribe to Hacking with Swift+ Browse Swift Courses Book bundles Frequently Asked Questions Lifetime Update Policy Frequent Flyer Club Buy on Apple Books Reader Reviews Refund Policy. About About Hacking with Swift Swift Community Awards Hacking with Swift Live Conference Talks Affiliate Program Newsletter Sponsor the site. SUBSCRIBE. WWDC23 SALE: Save 50% on all my Swift books and bundles! >>. This is another huge year of updates, delivering many highly requested features such as advanced scroll view effects, container relative sizing, and even Metal shaders. Paul Hudson    June 16th 2023    @twostraws. SwiftUI continues to evolve at a rapid pace, and this year has seen a huge number of improvements to scroll views, fun new SF Symbols effects, advanced support for Metal shaders, and more. Some of these are things I’ve asked for personally, including the ability to add Metal shaders, making Color work better with Codable , adding a completion closure for animations, allowing us to animate gradients, and being able to selectively round corners of a rectangle – I’ve closed at least a dozen feedbacks just from beta 1! SAVE 50% To celebrate WWDC23, all our books and bundles are half price , so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more. Save 50% on all our books and bundles! Scroll view improvements. How to make a ScrollView snap with paging or between child views. How to disable ScrollView clipping so contents overflow. How to make a ScrollView start at the bottom. How to indent the content or scroll indicators in a ScrollView. How to make views scroll with a custom transition. How to flash the scroll bar indicators of a ScrollView or List. How to enable vertical page scrolling. Drawing and animation improvements. How to add Metal shaders to SwiftUI views using layer effects. How to dynamically adjust the appearance of a view based on its size and location. How to animate SF Symbols. How to run a completion callback when an animation finishes. How to create multi-step animations using phase animators. How to combine shapes to create new shapes. How to adjust the size of a view relative to its container. More welcome improvements. How to add in-app purchases in SwiftUI. How to add an inspector to any view. How to detect and respond to key press events. How to control which NavigationSplitView column is shown in compact layouts. How to add haptic effects using sensory feedback. How to tell the user that no content is available. How to read the red, green, and blue values from a Color. How to make buttons that repeat their action when pressed. And there’s more… You might expect me to talk about SwiftData here, but I’m not – or at least not yet . Yes, it’s important, and yes it’s genuinely a huge step forward for all iOS developers, but I’m spending a lot of time writing test projects, experimenting, and getting answers to my questions, because I want to be really sure I understand it thoroughly before I write about it. However, there are other interesting SwiftUI changes to discuss: There’s improved API for filling and stroking shapes at the same time . The onChange() modifier now accepts 0 or 2 parameters, and can also be triggered by your initial value. The foregroundColor() modifier has been formally deprecated in favor of foregroundStyle() . Changing colors in a gradient will animate in iOS 17 and later. SwiftUI’s default animation is now a spring, there are many more built-in animations such as .bouncy and .snappy , and springs are now created with much simpler API . There’s new support for rounding some corners of a rectangle but not others. There’s newer, simpler syntax for making fill shapes and clip shapes: .rect , .capsule , and so on. When creating table views, we can now write ForEach(users) rather than ForEach(users, content: TableRow.init) And although it’s more of an Xcode improvement than a SwiftUI improvement, all images and colors defined in assets catalogs now have static names we can use in code rather than strings: Image(.dog) rather than Image("dog") , for example. There are also new APIs for performing keyframe animations, new map controls, and more – I’m still digging in, writing code samples, and finding techniques that work well. I particularly like some of the approaches taken in these new APIs, particularly the way things like scroll bar flashing, sensory feedback, and phase animations can be triggered using a simple Equatable comparison – it really lowers the complexity bar. So what about SwiftData? The dramatic and wide-ranging changes to data management in SwiftUI are really welcome. In fact, there’s a video of me actually letting out a scream during Apple’s State of the Union session at Apple Park – I’m really glad to see it arrive. However, it’s also something that takes care to get right. I’ll be updating my books for it – of course! – but I also want to make sure I understand the best practices for using it thoughtfully, so I hope you don’t mind a little delay while I’m conducting all my research. Thank you for your patience! SAVE 50% To celebrate WWDC23, all our books and bundles are half price , so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more. Save 50% on all our books and bundles! More articles. RSS feed. I screwed up one key accessibility behavior, and now I'm on a mission to do better. Hacking with Swift Live 2023. What’s new in Swift 5.9? Now available to pre-order: Swift Against Humanity. What's new in Swift 5.8. SwiftUI by Example: Now updated for iOS 16. WWDC22: Wrap up and recommended talks. How to use inner shadows to simulate depth with SwiftUI and Core Motion. Was this page useful? Let us know! Average rating: 4.6/5. Thank you! Click here to visit the Hacking with Swift store >>. @twostraws. paul@hackingwithswift.com. Sponsor the site. About             Glossary             Privacy Policy             Refund Policy             Update Policy             Code of Conduct. Swift, SwiftUI, the Swift logo, Swift Playgrounds, Xcode, Instruments, Cocoa Touch, Touch ID, AirDrop, iBeacon, iPhone, iPad, Safari, App Store, watchOS, tvOS, Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries. Pulp Fiction is copyright © 1994 Miramax Films. Hacking with Swift is ©2023 Hudson Heavy Industries. You are not logged in. Log in or create account. Link copied to your pasteboard.