Reading time: 2 min
This article is a cheatsheet for using system images/icons (SF Symbols) in SwiftUI. It shows all the ways to set their size, color and variants. The end results look like this:
Basics
System images or system icons refer to images that are present by default on Apple platforms. The image co...
SwiftUI Image Tint
Reading time: 1 min
This recipe shows how to tint SwiftUI images in two ways - by setting the template tint or color multiply. The end result looks like this:
Let's start by saying that foregroundColor has no effect here. With that out of the way, the recipe depends on what you want to do with the image, since...
SwiftUI Image from Assets
Reading time: 1 min
This quick recipe shows how to display an image from Assets catalog in SwiftUI.
Say that you've added your image to the Assets catalog:
All you have to do to render it on the screen is to pass its name to Image:
Image("logo_small")
Using Image(decorative:)
does the same thing.
Zoom Image in SwiftUI
Reading time: 4 min
This recipe shows how to zoom an image in SwiftUI using the pinch/magnify gesture. The image is zoomed in or out at the midpoint between the fingers, supports dragging and double tap to zoom in or reset. The end result looks like this:
The recipe goes as follows:
- Use a custom
UIVIew
wi...
SwiftUI Load Remote Image (Any Version)
Reading time: 3 min
This recipe provides a drop-in replacement for iOS 15 AsyncImage. This allows you to load images from remote sources on any SwiftUI version, with the code being exactly the same (minus the Compat
at the end of name :]). The end result looks like this:
AsyncImage
and AsyncImageCompat
bot...