SwiftUI

Migrating from UIKit to SwiftUI – Workable Strategies

The introduction of SwiftUI has brought a fresh, new look to iOS app development. With its declarative syntax and improved performance, it’s no wonder that many developers are eager to make the switch. However, migrating from UIKit to SwiftUI can…

Drawing paths and custom shapes in SwiftUI

To draw paths and custom shapes in SwiftUI, you can use the Path and Shape types provided by the SwiftUI framework. The Path type represents a geometric path in two-dimensional space, and it consists of a sequence of straight and…

Xcode Cheat Sheet – Most used shortcuts and tips

If you’re an iOS developer, it’s essential to have a thorough understanding of the tools you use on a daily basis. After all, you likely spend 40 or more hours a week working with them, so knowing small hacks that…

How to detect multiple gestures simultaneously?

If you want to detect multiple gestures at the same time, you can use SwiftUI’s simultaneously function. You can simply say that it is opposite of sequenced gestures described in How to implement sequential gestures using sequenced? For example, this…

How to implement sequential gestures using sequenced?

If you want to collaborate multiple gestures and make them detectable one after another, you can use SwiftUI’s sequenced modifier. To implement combined gestures or sequential gestures you need to create multiple gestures. In this case, the second gesture can…

How to pop or dismiss view programmatically in SwiftUI?

To pop or dismiss the view programmatically in SwiftUI, you can use use @Environment(\.presentationMode) as a variable and call wrappedValue.dismiss(). In the DetailView we have called wrappedValue.dismiss() wen the button is tapped. You can also get the same outcome if…

How to present detail view using NavigationLink in SwiftUI?

NavigationLink helps you to present new view or detail view from the navigation view. While using NavigationLink it pushes the a details view on the navigation stack with built in animation. To demonstrate this, the following code creates a DetailView…

How to show date picker in SwiftUI?

SwiftUI date picker is a very handy built-in modifier(DatePicker) for selecting a specific date, time, or both. A date picker has four modes: date, time, date and time, count down timer. You can display date picker in contact, wheels and…

How to show picker in SwiftUI?

SwiftUI’s dedicated picker can display one or more scrollable items from which you can choose your desired item. It is recommended to use pull-down menu instead of a picker if the list is not very long. A picker typically appears…

How to show a menu in SwiftUI?

SwiftUI menu is a versatile control for presenting a menu of actions. It supports submenus and the primary action from iOS 15. SwiftUI menu is more user friendly and advance than the action sheet. Let’s try a menu named “Manage…

How to show a context menu in SwiftUI?

The context menu provides you access to additional functionality related to onscreen items without cluttering the screen. You can create a context menu using .contextMenu modifier. The context menu is triggered with a long press. Each menu item in the…

How to show an action sheet in SwiftUI?

From iOS 15 you can present an action sheet using confirmationDialog() modifier. In SwiftUI, the action sheet shows a confirmation dialogue using data to produce the dialogue’s content and a localized string key for the title. You need to provide…

How to create background blur in SwiftUI?

Glassmorphism is a very trending UI design paradigm nowadays. We can use the semi-transparent blurry background to give more focus on the foreground content. SwiftUI provides .blur() modifier to create the background blur but it has very limited functionality compared…

How to create horizontal or vertical ScrollView in SwiftUI?

ScrollView in SwiftUI presents its content within the scrollable region. ScrollView can scroll horizontally, vertically, or both. The alignment of the ScrollView is vertical. If you want to make it horizontal then you need to use the horizontal parameter for…

Built-in shapes in SwiftUI

Shapes in SwiftUI are a very innovative, exceptionally simple way to build a user interface component. In this article, we will take a look at simple shapes like rectangle, rounded rectangle, ellipse, circle and capsule. The common use of built-in…

How to show an alert in SwiftUI?

iOS 15 makes the alert presentation a piece of cake. You can show an alert using the alert() modifier. Buttons inside the alert will dismiss the alert view when it is tapped. You can create multiple buttons inside an alert.…