How to fill and stroke basic shapes in swiftUI?

By | October 9, 2024

In latest iOS versions ( ios 17 onwards) we can directly put stroke and fill shapes just by adding modifiers one after another as shown below. It works with multiple strokes of various sizes as shown below. In older versions of iOS ( iOS 16 ) SwiftUI provides the fill(), stroke(), and strokeBorder() modifiers for adjusting the way we… Read More »

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 add image as background in swiftUI?

By | October 4, 2024

In swiftUI, apple doesn’t provide any dedicated background image or color modifier. It lets us add any kind of background view using its background() modifier. For example, this creates a text view with a large font, then places a 100×100 image behind it. However, it doesn’t need to be an image all the time. For example, this… 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 expose swift class to react native class?

By | September 10, 2024

There will be situations where you have to expose your Swift class to React Native. To do this, you need to use some Obj-C Macros available in React Native. To use these Obj-C Macros, you need a new Obj-C file: You have to import RCTBridgeModule, so that you can use the Macros to bridge the native… 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 »

3 Simple ways to use Debouncer in Flutter

By | August 26, 2024

Watch Video Tutorial Using Simple Timer Create a simple debouncer class Implementation: Using ValueNotifier Implementation: Using “Simple Debouncer” package First Add easy_debouncer package in your dependencies https://pub.dev/packages/easy_debounce Source Code https://github.com/MrVipinVijayan/flutter_tutorials/tree/feat/debounce

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 »

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. Find the minimum element in O(log N) time. You may assume the array does not contain duplicates.

By | August 22, 2024

To find the minimum element in a rotated sorted array in O(log⁡N)O(\log N)O(logN) time, you can use a modified binary search approach. The key observation is that even though the array is rotated, one part of the array will still be in sorted order. By comparing elements in the middle of the array with the… Read More »

How to adjust text alignment using multilineTextAlignment()

By | August 13, 2024

Like many other text UI’s SwiftUI’s Text wraps across multiple lines, they align to their leading edge by default. You can change that behavior, by using swiftUI’s ‘multilineTextAlignment()’ modifier to specify an alternative like .center, .trailing etc. For example, this will center several lines of text as they wrap across lines: Let’s use a picker… 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 »

Given a 2D board of characters and a word, find if the word exists in the grid.

By | August 5, 2024

The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. For example, given the following board: exists(board, “ABCCED”) returns true, exists(board, “SEE”) returns true, exists(board, “ABCB”) returns false. Python def exist(board, word):    if not board:        return False   … Read More »

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 »