How to display a view frame size for debugging

In this SwiftUI tutorial, you will learn what a GeometryReader is and how to use it to prepare a modifier that will display size and dashed frame around a view. It can be handy for debugging. The image above presents the effect of applying a frameSize modifier. What is GeometryReader? According to …

How to control image resize zones with capInsets

A resizable modifier that you can apply to the SwiftUI Image can be useful not only for scaling or setting the aspect ratio of a given view. You can use it to scale small image files correctly and stretch only part of them. If you are familiar with Android resizable bitmaps (9-patch files) using the …

How to create a custom ViewModifier

Making a User Interface (UI) with SwiftUI combines three activities: you will be creating new and arranging existing Views, modifying the State of your app, and transforming Views to new ones using ViewModifiers (or just modifiers for short). I’ll explain how you can make your modifiers by …

How to display, scale, and resize an image

Images, along with shapes, colors, and texts, are essential ingredients of all applications UIs. Displaying images in SwiftUI is easy. You have to add your image file to the assets catalog and then use Image view to present it on screen. Image("logo") Resize You will quickly notice that the …

How to use interpolatingSpring for physics-based Animation

SwiftUI offers a very convenient way to display simple value-based animation. By adding an animation modifier, you can tell that you want to animate other modifier value changes. Additionally, with SwiftUI, you get many Animations like easeIn, easeOut, or linear. There are also Animations that …

How to preview and debug WidgetKit views

SwiftUI offers an easy way to preview changes in your views without compiling and running the application. Introduced in iOS 14 and macOS 11, WidgetKit widgets are SwiftUI (static) views so that you can use the same functionality for them.You can display iOS and macOS widgets in three sizes called …

How to display a date using Text view

SwiftUI has a very convenient way to display dates. It provides a special Text initializer that receives date and style. You can pick from a list of five available DateStyles: time, date, relative, offset, and timer. Each one displays time in a different format. let now = Date() // Dec 6, 2020 at …