Tag Archives: swiftUIProgramming

How to display solid shapes in swiftUI?

By | October 6, 2024

Sometimes we need to display basic shapes in our apps just to get more attractive UI or just to highlight something. SwiftUI has several build in shapes to help the user to ease the development. It has several built-in shapes such as rectangles, circles, and capsules, each of which can be created, color, and positioned… Read More »

How to play movies with VideoPlayer

By | September 29, 2024

Playing movie or videos from any source is important when it comes to application development. Apple provides some default frameworks to handle it. SwiftUI’s VideoPlayer view lets us playback movies from any URL, local or remote. It comes from the AVKit framework, this can be added to the framework by importing AVKit. The below example shows how… Read More »

How to render images in swiftUI using SFSymbols?

By | September 24, 2024

SFSymbols are one of the best feature provided by apple to the developers. It provides vast list of icons that can be scaled and modified as per our need. These images provides consistency across our all screens and apps without any additional effort. SwiftUI’s Image view helps us to load over 2500 SF symbols without… Read More »

Rendering mark down content in text

By | September 16, 2024

Quite often, while dealing with text contents, we come across questions like ‘how to render mark down content in text?’ SwiftUI has built-in support for rendering Markdown, including bold, italic, links, and more. It’s literally built right into SwiftUI’s Text view, so you can write code like this: The link is tappable and it will be ind… Read More »

How to use privacySensitive in swiftUI?

By | August 27, 2024

SwiftUI lets us mark some parts of our view as containing sensitive information, which in practice allows us to hide or show it more easily using redaction. To use this feature in your code, first add the privacySensitive() modifier to any views that should be hidden, then apply the .redacted(reason: .privacy) modifier at a higher place in your view… Read More »

Placeholder for text using redacted()

By | August 25, 2024

In our view we can mark a text as placeholder, meaning that it gets rendered but masked out with gray to show it isn’t final content. This is provided through the redacted(reason:) modifier, along with an unredacted() modifier you can use to override redaction as needed You can redact several things in your view at once, just by using redacted(reason:) on… Read More »

Format text inside text view.

By | August 12, 2024

From iOS 13 onwards apple has introduced text formatting API named ‘Format’ and it is capable of showing dates, arrays and measurements and more. If you use the .list() format type with an array of strings, you can get neatly formatted lists such as “Jay, Modi, and Webber”. For example, this will print ingredients lists correctly no… Read More »

How to add advanced text styling using AttributedString in swiftUI?

By | August 5, 2024

In our previous post we talked about styling swiftUI text views with fonts, colors, line spacing and more. This time we will look deep into ‘AttributedString’. SwiftUI’s ‘Text’ view is able to render more advanced strings created using ‘AttributedString’ struct. This includes adding underlines, strike through, web links, background colours etc. We will show you… 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 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 »