XCode 12 — iOS 14

In this tutorial, We are going to implement CrossDissolve slide animation for Tab bar view.

We cannot achieve CrossDissolve animation in SwiftUI itself, unless we create custom tab bar. In this tutorial, We are going to implement crossDissolve for native Tab-bar.

As Tabbar does not give any API to add custom animation, We are going to inspect Tab-bar for UIKit’s UITabbar. After getting UITabbar, we implement the animation.

To get UITabbar using following library.

import SwiftUI
import Introspect //To Get UIView in view hierarchy
@main struct LoopingVideoApp: App { var body: some Scene { WindowGroup…

Flow chart for various app architecture

Xcode 12 — iOS 14

In this tutorial, We will be converting ScrollView’s content into a UIImage.
First, we will convert any view into the UIImage then we will extend the same logic to screenshot the entire Scroll view content.

  1. Create an extension on SwiftUI’s view, which takes the position of part of the view we need to convert into an image. We will create a dummy UIHostingViewController with the given frame. From UIHostingView controller, we will access UIKit’s view.
extension View { func takeScreenshot(origin: CGPoint, size: CGSize) -> UIImage { let window = UIWindow(frame: CGRect(origin: origin, size: size)) let hosting = UIHostingController(rootView: self) hosting.view.frame…

Source: Bloomberg

In-App purchase is one of the most convenient payment method for iOS Apps but Apple’s 30% cut takes out big Chunk. The Apple policy force virtual goods to be purchased only via Apple’s in-app purchase. When I use to work with a gaming company, I understand some work around to bypass this.

1. Adding physical goods with virtual one: For larger amount of In app purchase, add a physical good with it like T-shirt and create separate segment for it. And in this segment you can add credit cards etc. …

Various methods to store/read data in iOS App

In this tutorial, We are going to learn ways to read, write, store data.


A simple understanding is the resource file package, which will organize many pictures, xibs, and text files together and package them into a Bundle file. A main bundle get packaged with App. There can be separate bundle for individual library used in app.

//Access the main bundlelet bundle = Bundle.main
let jsonFile = Bundle.main.path(forResource: “xxx”, ofType: “json”)

**Every time when user update app the main bundle also gets an update.


In a Non-Rooted iPhone/iPad device, An App can only perform file operations in the file…

Multiline Text field Xocde 12 — iOS 14 [iOS 13 support here]

When using default Swift 2.0 TextEditor. There is no direct way to add palce holder. Even setting background color, changing text cursor color is not straight forward. In this tutorial we are going to implement all the basic text editor functionality missing in TextEditor.

Setting Placeholder, to set placeholder we are going to create a custom TextEditor view. This text editor will be wrapped by Zstack. This ZStack will also contain placeholder text label with will be visible if no text has been added to the TextEditor

struct CustomTextEditor: View { let placeholder: String @Binding var text: String let internalPadding…

Pull down to refresh data in SwiftUI — Xcode 12-iOS 14

In this tutorial, We are going to implement Pull to refresh using only SwiftUI components.

We are going to divide this problem in two parts:

  1. Logic to detect if user pull down the scroll view
  2. Add Progress view and pull down loader animations

Logic to detect if user pull down the scroll view, We are going to use coordinator space of ScrollView with Child GeometryReader view. This will help us evaluate if user have pulled the view and How much user have pulled the view. If user have pulled the scroll view significantly (50 px in our case). …

Xcode 12 — iOS 14

In this tutorial, We are going to implement a UIKit like search without using any UIViewRepresentable.

We are going to divide the problem in following segments

  1. Create a search bar UI
  2. Add this search bar to List header

Create a search bar UI:

Search bar have a magnifying glass, an x button if text visible, and the cancel button to dismiss the search. We going to put all this in HStack with show/hide animation for cancel and x button.

Add this search bar to List header

We are going to use this Search bar in a list leader like following:

If we try now out search bar will look something…

SwiftUI + Visionkit — iOS 14 Xcode 12

With Apple’s Visionkit, It is super easy to create a document scanner. In this demo we are going to build MVP in less than 100 line.

In this document scanner, We are going to support following feature:

  1. Scan one or multiple documents
  2. Share the Scanned Document
  3. Delete if Document is not needed

*Complete code at the end

Considering you have already created an empty project.

Step 1: Camera permission

Add NSCameraUsageDescription to info.plist

your access request message</string>

Step 2:

Create a base UI, With a button using which user can open camera to scan document.

Step 3: present VNDocumentCameraViewController on user tap:

We init and set delegate for VNDocumentCameraViewController in ContentView…

Xcode 12 — iOS 14

We are going to divide this problem into 2 Parts.

  1. Detecting if text can/cannot fit in given number of line. On Button click reset line count for text.
  2. Evaluating text size to add read more/read less at the end to text in the last line and handle click event shrink and expand.

Detecting if text can/cannot fit in given number of line:

To evaluate if the text string going to truncate or not, We will have to render the text string two times. One with line limit another without line limit.

We are going to leverage main text view’s background view for the same. Also…

Prafulla Singh

iOS Developer | Swift | Flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store