Advanced SwiftUI Animations – Part 6: CustomAnimation

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 SwiftUI Layout Protocol – Part 2

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 SwiftUI Layout Protocol – Part 1

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

Eager Grids with SwiftUI

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

SwiftUI Renderers and Their Tricks

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

WWDC 2022: Lessons from the SwiftUI Digital Lounges

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

SwiftUI ’22 in Numbers (and a few Charts)

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

Advanced SwiftUI Animations – Part 5: Canvas

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

Advanced SwiftUI Animations — Part 4: TimelineView

Film Strip

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

Random Lessons from the SwiftUI Digital Lounge

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

SwiftUI ’21 in Numbers

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

Attributed Strings with SwiftUI

Attributed String Banner

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

NSUserActivity with SwiftUI

NSUserActivity

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

Impossible Grids with SwiftUI

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

MatchedGeometryEffect – Part 2

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

MatchedGeometryEffect – Part 1 (Hero Animations)

MatchedGeometryEffect

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

Backward Compatibility with SwiftUI

Puzzle

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

WWDC 2020 Has Come and Gone

WWDC20

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

Working with Focus on SwiftUI Views

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 Power of the Hosting+Representable Combo

Powerful Combo

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

Drag & Drop with SwiftUI

Drag and Drop banner

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 Mystery Behind View Equality

Equal Benner

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

id(_): Identifying SwiftUI Views

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

Safely Updating The View State

Semaphores

If you’ve been using SwiftUI for a while now, you probably hit the problem where you find yourself trying to update the state of a view from inside its body. Usually, Xcode complains during runtime. When it does, you are forced to put your update inside a DispatchQueue closure (not feeling too good about yourself) … Read more

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close