Hello! Kamil

How to add home screen Quick Actions to SwiftUI app

A long-press or force touch on the iOS app icon brings a menu called home screen Quick Actions. Developers can put up to 4 buttons there for compelling, high-value tasks. It is a UIKit functionality, but you can use that in your SwiftUI app, too. How to add Quick Action? There are two kinds of quick …

How to display SwiftUI view in Swift Playgrounds

One of the most significant advantages of cross-platform frameworks like React Native or Flutter is hot reloading. During development, you can see recent code changes without recompiling and rebuilding. SwiftUI offers a similar but somehow limited functionality called live preview. It works only for …

How to access UserDefaults using AppStorage property wrapper

WWDC20 SwiftUI updates straight forwards UserDefaults access by introducing @AppStorage property wrapper. This article will explain how to store and read simple types like integer, string, double, data, or URL. UserDefaults is a simple key-value storage that can store a limited number of simple …

How to use Picker to create a segmented control

A SwiftUI Picker view is a control that lets you pick a value from a set of options. The Picker will adjust its looks to the context (different for iOS, macOS, or watchOS). It can look like the UIKit component called a UISegmentedControl (or segmented control) with proper configuration. You can use …

How to display SF Symbols in SwiftUI

Apple provides over 2400 high-quality and highly configurable symbols integrated under the SF Symbols name and available for iOS 13 and macOS 11 and later. You can easily use them in your SwiftUI application to achieve a look consistent with other system applications. The 2020 update (SF Symbols 2) …

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 …