NavigationStack & NavigationLink in SwiftUI

NavigationStack NavigationStack helps to navigate between multiple views, shows titles in views, and enables a navigation bar on the top for us. Here is a simple example: Output will be like this: NavigationLink NavigationLink uses to link another view to the root view. If we visit the child view, NavigationStack will automatically add a Back … Read more

List in SwiftUI

In SwiftUI, list is a container where we can add scrollable items. It presents rows of data arranged in a single column. Here is a simple example of List view in SwiftUI. Output: We can create list of multiple view item too: Output: You can create dynamic list like this: Output: We can create a … Read more

SwiftUI Button

There are several ways to create a button. Here is the simplest form: Action area where you will execute code while button is pressed. We can create simple counter app using Button and Text view: Output: We can use Image, Text or both as Button label: Output: You can style button as you need like: … Read more

Image view in SwiftUI

Working with image in SwiftUI is so easy. There are several way we can add image to our project. Using image from Assets.xcassets If we put an image in Assets.xcassets, we can use in our app like this: We can resize and make it fit into available space like this: We will get output like … Read more

TextField & TextEditor in SwiftUI

TextField To read text input from user, we can use TextField. To use TextField, we need a placeholder to hold the value entered in the TextField. For that, we need to pass a binding variable. Here is a quick example: Output: When user pass a name, Text view will be updated. We can customise TextField … Read more

SwiftUI Text and Label

Text To show text in SwiftUI application we just need to write: Text Styling SwiftUI is a powerful UI framework. We can achieve anything we want using it’s styling modifiers. Like: Instead of writing code, you can add style to any view from Inspector view from right panel: Text with variables We can simply pass … Read more