If you find yourself trying to modify the state of view while its body is computed, here you can learn what are the "Do's and Don'ts".| The SwiftUI Lab
In part 6 of the Advanced SwiftUI Animations series, I covered the CustomAnimation protocol, one of the many new additions introduced at WWDC ’23. But the fun does not end there. Now it is time to look at a new view: PhaseAnimator. If you have been playing around with this new toy, you may have ... Read more The post Advanced SwiftUI Animations – Part 7: PhaseAnimator appeared first on The SwiftUI Lab.| The SwiftUI Lab
Welcome to a new installment of the Advanced SwiftUI Animations series. I initiated this collection of articles back in 2019. Since then, Apple has been enhancing the framework and introducing new features. This year is no exception, with exciting additions that expand the possibilities of SwiftUI animations. As always, my goal is to explore every ... Read more The post Advanced SwiftUI Animations – Part 6: CustomAnimation appeared first on The SwiftUI Lab.| The SwiftUI Lab
And the Fun Begins! In the first part of this post we explored the basics of the Layout protocol in order to build a strong foundation of how Layout works. Now it’s time to dive into the less commented features and how to use them in our benefit. Part 1 – The Basics: Introduction What ... Read more The post The SwiftUI Layout Protocol – Part 2 appeared first on The SwiftUI Lab.| The SwiftUI Lab
Introduction One of the best SwiftUI additions this year has to be the Layout protocol. Not only we finally get our hands in the layout process, but it is also a great opportunity to better understand how layout works in SwiftUI. Back in 2019 I wrote an article about Frame Behaviors with SwiftUI. In it, ... Read more The post The SwiftUI Layout Protocol – Part 1 appeared first on The SwiftUI Lab.| The SwiftUI Lab
Introduction Back in 2020 we got new views to draw grids in SwiftUI (LazyVGrid and LazyHGrid). Two years later, we are getting yet another view to display views in a grid (Grid). However, these new addition is very different, not only in the way you use it, but also how it behaves internally. The views ... Read more The post Eager Grids with SwiftUI appeared first on The SwiftUI Lab.| The SwiftUI Lab
In Xcode beta 3, ChartRenderer has been removed from the SDK. It seems we now should start using ImageRenderer instead to render charts. I had a feedback raised due to the ChartRenderer working monochrome, and with beta 3, I got a reply saying “ChartRenderer was removed. We suggest you use ImageRenderer instead”. This statement seems ... Read more The post SwiftUI Renderers and Their Tricks appeared first on The SwiftUI Lab.| The SwiftUI Lab
This has been the second year of WWDC Digital Lounges. They gave us a good opportunity to try getting our questions directly answered by the makers of SwiftUI (and other frameworks). Not everyone has been able to attend, probably due to other commitments, lack of time, failure to register, unfortunate timezones, etc. However, again this ... Read more The post WWDC 2022: Lessons from the SwiftUI Digital Lounges appeared first on The SwiftUI Lab.| The SwiftUI Lab
After posting this article, I realized that due to a bug in SourceKit, the numbers here are a bit underestimated. They do not include the Charts API types, methods and properties. SourceKit is currently crashing when trying to open the interface file of the Charts API. I will update the numbers as soon as sourcekit ... Read more The post SwiftUI ’22 in Numbers (and a few Charts) appeared first on The SwiftUI Lab.| The SwiftUI Lab
This fifth part of the Advanced SwiftUI Animations series will explore the Canvas view. Technically, it is not an animated view, but when combined with TimelineView from Part 4, it brings a lot of interesting possibilities, as shown in this digital rain example: I had to delay this article several weeks because the Canvas view ... Read more The post Advanced SwiftUI Animations – Part 5: Canvas appeared first on The SwiftUI Lab.| The SwiftUI Lab
It’s been two years since I published Part 3 of this series of articles about Advanced SwiftUI Animations. I’m super excited about this year’s WWDC introduction of TimelineView and Canvas. It opens a whole new range of possibilities that I will try to lay out in this and the next part of the series. In ... Read more The post Advanced SwiftUI Animations — Part 4: TimelineView appeared first on The SwiftUI Lab.| The SwiftUI Lab
One of this year’s WWDC highlights was the introduction of the Digital Lounges. Unfortunately, it was as good as it was ephemeral. In an instant… puff! it was gone! Many weren’t able to attend due to other commitments, lack of time, failure to register, etc. I personally failed to follow them as closely as I ... Read more The post Random Lessons from the SwiftUI Digital Lounge appeared first on The SwiftUI Lab.| The SwiftUI Lab
WWDC ’21 is finally here and it brought a lot of new toys to play with. In the upcoming weeks I will be writing new articles and will update the Companion for SwiftUI app to include all the new SwiftUI features introduced this year. In anticipation, a week ago I released a beta version of ... Read more The post SwiftUI ’21 in Numbers appeared first on The SwiftUI Lab.| The SwiftUI Lab
In the last few weeks, I have been asked frequently about how to work with attributed strings and SwiftUI, so I decided to write an article to share what I know about the topic. Before we begin, let’s put it right there: SwiftUI is not prepared to handle attributed strings easily. With that out of the way, ... Read more The post Attributed Strings with SwiftUI appeared first on The SwiftUI Lab.| The SwiftUI Lab
When I was researching NSUserActivity in order to expand the content of the Companion for SwiftUI app, I found that there is a lot of outdated information and confusing examples out there. For instance, most articles about Handoff are from the time the feature was added. But when that happened, scenes did not exist yet. ... Read more The post NSUserActivity with SwiftUI appeared first on The SwiftUI Lab.| The SwiftUI Lab
Native support for grids in SwiftUI is finally here. This is made possible by two new views. These are LazyVGrid and LazyHGrid. From now on, when I write Lazy*View, I will be referring to both of them. In this article, we will first cover the basics, but then we will go a little beyond the common grids with ... Read more The post Impossible Grids with SwiftUI appeared first on The SwiftUI Lab.| The SwiftUI Lab
With the release of Xcode 12 beta 4, two bugs mentioned in this articles got fixed! I marked those sections with a note, but will keep the sections for a couple of weeks, in case some readers are still using an older beta. The elimination of those bugs will make our life easier. In fact, ... Read more The post MatchedGeometryEffect – Part 2 appeared first on The SwiftUI Lab.| The SwiftUI Lab
This year brought some interesting new additions to the SwiftUI framework. There is one, in particular, that opens a whole lot of new possibilities. We are talking about a new extension to the View protocol, the .matchedGeometryEffect() modifier. On its own, it’s good enough, but in combination with other techniques we learned already (custom transitions ... Read more The post MatchedGeometryEffect – Part 1 (Hero Animations) appeared first on The SwiftUI Lab.| The SwiftUI Lab
On your mark, get set, go! The time to begin discovering all the new SwiftUI features that the WWDC 2020 brought is here. However, as every year, excitement washes off a few milliseconds later, when you remember that dropping support for older OS versions is not an option for you. Usually, we resort to our ... Read more The post Backward Compatibility with SwiftUI appeared first on The SwiftUI Lab.| The SwiftUI Lab
WWDC 2020 finally arrived. I bet you are excited with all the new toys we’ve been given. I sure am! In the upcoming weeks, I know I will be busy updating the blog. Both revising all articles and writing new ones. I will be also updating the Companion for SwiftUI app, to make sure it ... Read more The post WWDC 2020 Has Come and Gone appeared first on The SwiftUI Lab.| The SwiftUI Lab
In this post, we are going to explore what tools SwiftUI offers to handle the focus on custom views. We will also explore the limitations, and what hacks we can use to get around them. SwiftUI on macOS has a single modifier to configure our view focus: focusable(). It receives two optional parameters (more on ... Read more The post Working with Focus on SwiftUI Views appeared first on The SwiftUI Lab.| The SwiftUI Lab
If you are allergic to hacks, you should probably stay away from the code in this article. However, if you continue, know that we will explore the powerful effects of combining Hosting Views with View Representables. Many times I found myself with a SwiftUI view and wishing I could access the AppKit/UIKit stuff behind it. ... Read more The post The Power of the Hosting+Representable Combo appeared first on The SwiftUI Lab.| The SwiftUI Lab
SwiftUI incorporates some methods and protocols to easily perform Drag and Drop operations. Until iOS 13.4, most of these methods were macOS exclusive. Fortunately, that changed with the latest iOS13.4 beta release. Drag and Drop with SwiftUI is very simple. However, if you are completely new to drag and drop on macOS/iOS, the challenge will ... Read more The post Drag & Drop with SwiftUI appeared first on The SwiftUI Lab.| The SwiftUI Lab
At the time of this writing, if you looked for EquatableView on Google, you would only hear crickets. So I decided to investigate this view myself. After banging my head against the monitor, I finally realized the main reason I wasn’t getting anywhere, is the fact that there is some implicit behavior going on. In ... Read more The post The Mystery Behind View Equality appeared first on The SwiftUI Lab.| The SwiftUI Lab
In this article, we will explore how SwiftUI uses the .id() method to identify a view. This is a method that has been the source of a lot of speculation. The question we all ask ourselves is: What is it good for? Well, we’ll see that the obvious answer is not necessarily the right answer. ... Read more The post id(_): Identifying SwiftUI Views appeared first on The SwiftUI Lab.| The SwiftUI Lab