Category: SwiftUI

  • Adapting Text Colour for Dark Mode in SwiftUI

    In SwiftUI, ensuring text colour adapts appropriately to dark mode is crucial for readability. If your app supports an automatic appearance mode, the text colour needs to adjust dynamically based on the system’s appearance settings. Here’s a simple way to implement this: This code snippet checks if the darkMode setting is set to .auto. If…

  • Understanding State Management in SwiftUI

    State management is a crucial aspect of building dynamic and responsive applications in SwiftUI. For beginners, understanding how to manage state effectively can significantly enhance your ability to build robust applications. Let’s explore how to use various state management techniques in SwiftUI using an example of an expense split app. We’ll cover @State, @Binding, @StateObject,…

  • Building Your First iOS App: UIKit

    Welcome to the foundational guide to building iOS apps using UIKit, Apple’s traditional framework for constructing and managing user interfaces. In this tutorial, you will learn how to create a basic iOS app using UIKit, focusing on essential components such as views, view controllers, and user interaction. By the end of this guide, you’ll understand…

  • SwiftUI: Building Your First App

    Welcome to the exciting world of app development with SwiftUI! If you’re new to SwiftUI, this guide is designed to introduce you to the fundamentals of building an iOS app using this innovative framework. By the end of this tutorial, you will have a basic understanding of SwiftUI’s core concepts, including views, modifiers, and state…

  • Managing Dark Mode and Light Mode in iOS Apps

    In today’s mobile apps, supporting both dark mode and light modes isn’t just a nice to have it’s often expected by users who want their apps to integrate seamlessly with their device settings. Dark mode provides a darker colour palette for all screens, views, menus, and controls, and it’s beneficial for both reducing eye strain…

  • How to simplify persistent data using @AppStorage

    In SwiftUI, the @AppStorage property wrapper that assists how we interact with UserDefaults, streamlining the process of persisting data. By simplifying data persistence, @AppStorage makes reading from and writing to UserDefaults more straightforward and integrated within the SwiftUI framework. Let us take the following example where we are trying to store tap count in User…

  • How to detect availability of internet connection in Swift

    In today’s world, mobile apps are a big part of our lives. Many of these apps need an internet connection to work properly. This is why it’s so important for app developers to make sure users have a smooth experience, whether they are connected to the internet or not. On iOS devices, developers can use…

  • Understanding .onAppear and .onDisappear in SwiftUI

    SwiftUI simplifies the way developers think about the lifecycle of views with its declarative syntax. Unlike UIKit, which requires you to manage the lifecycle through methods like viewDidLoad, viewWillAppear, and viewWillDisappear, SwiftUI provides .onAppear and .onDisappear modifiers for executing code when a view appears or disappears. This tutorial demonstrates how to use these modifiers in…