Tag Archives: swiftUI

Styling swiftUI text views with fonts, colors, line spacing and more

By | July 10, 2024

A text view draws a string in your app’s user interface using a body font that’s appropriate for the current platform. You can choose a different standard font, like title or caption, using the font(_:) view modifier. Text views give us predictably wide range of controls in terms of how they look. They are also designed to work seamlessly alongside core apple… Read More »

How to customise NavigationStack background in swiftUI?

By | June 15, 2024

The view background can extend to the corners of the view. This will affect the navigation bar background. This will go behind large and inline navigation bars. For example, in below example the background colour is applied to the whole screen, but it is covering the navigation bar background too. The new initializer introduced with… Read More »

How do I implement pull to refresh in SwiftUI?

By | June 11, 2024

There are two main approaches to implementing pull-to-refresh functionality in SwiftUI, depending on your SwiftUI version and desired level of customization: 1. Using the built-in refreshable modifier (iOS 16+) If you’re targeting iOS 16 and above, SwiftUI offers a built-in refreshable modifier that simplifies pull-to-refresh functionality for List and ScrollView. Here’s how to use it:… Read More »

How to use ‘AsyncImage’ in swiftUI?

By | May 27, 2024

AsyncImage is a component introduced in SwiftUI to handle the loading and displaying of remote images asynchronously. It simplifies the process of fetching images from the web, handling the loading state, and displaying a placeholder until the image is ready. Here’s a detailed breakdown of how AsyncImage works, its customisation options, and usage examples. Basic… Read More »

What are higher order functions in swift ?

By | February 28, 2024

Higher-order functions in Swift are functions that take other functions as parameters or return functions as output. They enable a functional programming style by allowing you to compose functions, pass behavior as arguments, and manipulate collections with concise and expressive code. Here are some common higher-order functions in Swift with examples: map(_:): filter(_:): reduce(_:combine:): sorted(by:):… Read More »

What is inout parameter in swift?

By | January 24, 2024

In Swift, inout is a keyword used to indicate that a parameter is passed by reference and can be modified inside a function, affecting the original value outside the function. This allows a function to modify the value of the parameter and have those changes reflected in the calling scope. Here’s an example to illustrate… Read More »

How to use BlockOperation in swift?

By | January 17, 2024

In Swift, BlockOperation is a subclass of Operation that allows you to encapsulate the code you want to execute concurrently. You can use it to create operations that consist of one or more blocks of code. Here’s an example of how to use BlockOperation: In this example: The OperationQueue takes care of managing the concurrent… Read More »

How to do navigation and data pass in swiftUI?

By | January 14, 2024

In SwiftUI, navigation is typically handled using the NavigationView and related components. Here’s a basic guide on how to perform navigation in SwiftUI: Basic Navigation with NavigationLink: 2. Creating NavigationLinks: 3. Creating the Destination View: 4. Putting it All Together: Passing Data with NavigationLink: 2. Receiving Data in Destination View:In the destination view, define a… Read More »

What are the difference between UIKit and SwiftUI in iOS?

By | January 14, 2024

UIKit and SwiftUI are both UI frameworks used in iOS development, but they differ significantly in terms of design, architecture, and development approach. Here are some key differences between UIKit and SwiftUI: 1. Declarative vs Imperative 2. UI Layout 3. Code re-usability 4. Live preview 5. UI Representation 6. State management 7. Adoption and Legacy… Read More »

How data is passed from one view to another in SwiftUI?

By | January 13, 2024

In SwiftUI, you can pass data from one view to another using the @State, @Binding, @ObservedObject, or @EnvironmentObject property wrappers. The appropriate choice depends on the nature of the data and the relationship between the views. Below are brief explanations and examples for each approach: 1. @State : Use @State to store simple values within… Read More »