In this post, we will learn how to use existing UIKit ViewControllers in the SwiftUI project. This tutorial will allow you to prepare your UIKit ViewController for Xcode Preview.


I think that SwiftUI and Combine will change the way people will write code in 2 years. In this post, we will discuss how to start using SwiftUI in an existing UIKit project so that you can have a smoother transition to SwiftUI projects. Especially if your application support starts from iOS 13, you should do that transition.


SwiftUI provides us with various modifiers for drawing borders on views and shapes. Specifically: stroke, stroke border, and border. At first glance, those modifiers may look identical, but they have different behavior and different places where they can be applied.


@GestureState is a property wrapper that stores states of a view during the performance of a gesture. That’s cool, but we can store the state of a view during the performance of a gesture using @State property wrapper.


While working with gesture recognizers, we might find ourselves having multiple gestures recognizers on the same view. And for such situations, we need exactly to know how those interact with each other. SwiftUI allows us to handle such cases in three-way: Simultaneous, Sequenced, Exclusive.


SwiftUI gives us an elegant and easy way of working with gestures. At the moment of writing this post, SwiftUI provides us with five gestures: DragGesture, LongPressGesture, MagnificationGesture, RotationGesture, and TapGesture.


Padding allows us to add space around views. We cand do that using the “padding()” modifier. By default, padding will add a default space provided by the system, which conforms to the Apple Human Interface Guidelines.


Gradients conform to view protocol, which means that we can drow them as any other view. SwiftUI provides us with three types of gradients: linear, angular, and radial. Each type requires a few different parameters.


SwiftUI is a powerful framework that provides us with a lot of built-in stuff, such as support of apple human interface guidelines. But sometimes even if SwiftUI views arrangement follows the apple human interface guidelines, they don’t align as our designer may want.


In this post, we will discuss how to compute one alignment in terms of other alignments. In the following example, we have two texts and one image.