SwiftUI
Learn more and get better in building apps with SwiftUI.
View Composition using ViewModifiers in SwiftUI
View Composition allows you to create reusable components to create enriched views. You can extract logic into reusable components using the ViewModifier protocol in SwiftUI and set up your code for reusability. I've been developing a set of view modifiers in RocketSim to enable TextField customizations. Combining all modifiers results ...
Introducing Roadmap: Offer Public Feature Voting
Roadmap is a new open-source framework written completely in Swift and SwiftUI, allowing you to integrate feature voting functionality for your apps. While developing apps, spending your time on the most impactful features is essential. While the definition of impactful divers it's certainly driven by what your users want to ...
How to use FormatStyle to restrict TextField input in SwiftUI
A custom FormatStyle can help you control the allowed characters of a SwiftUI TextField. You might want to allow numbers only or a specific set of characters. While you could use a formatter in many cases, it's good to know there's a flexible solution using a custom FormatStyle implementation. In ...
Sheets in SwiftUI explained with code examples
Sheets in SwiftUI allow you to present views that partly cover the underlying screen. You can present them using view modifiers that respond to a particular state change, like a boolean or an object. Views that partly cover the underlying screen can be a great way to stay in the ...
Alternate App Icon Configuration in Xcode
Adding alternate app icons to your app allows users to customize their home screen with an app icon that fits their style. An alternative icon could be a dark or light-mode version of the original icon or a collection of completely different styles. iOS 10.3 was the first version to ...
Variable WidgetBundle configuration based on conditions
The WidgetBundle protocol inside WidgetKit allows you to configure supported widgets for your apps. Whenever you add one or more widgets, you'll have to add a @main struct conforming to this protocol. Like SwiftUI views, you'll return the supported widgets inside the body computed property. You'll not have issues with ...
Accessibility in SwiftUI explained for UIKit developers
Adding accessibility support in SwiftUI will be more approachable for you compared to UIKit. But still, if you’ve been sharpening your UIKit skills for years, it takes a while to get your head around the new declarative/reactive way of doing things. It is an entirely different mental model, and it ...
VoiceOver navigation improvement tips for SwiftUI apps
VoiceOver navigation support in your apps comes with the same requirements as navigating through touch controls. When navigating apps with standard touch controls, we tend to dislike apps that feel cluttered or make us do many interactions to achieve something. We'd probably say such an app does not offer a ...
@ViewBuilder usage explained with code examples
The @ViewBuilder attribute is one of the few result builders available for you to use in SwiftUI. You typically use it to create child views for a specific SwiftUI view in a readable way without having to use any return keywords. I encourage you to read my article Result builders ...
UIViewRepresentable explained to host UIView instances in SwiftUI
Adopting the UIViewRepresentable protocol allows you to host UIView instances in SwiftUI. Your SwiftUI code is converted to UIKit views behind the scenes. SwiftUI requires you to declare the view representation, but the underlying SwiftUI implementation will optimize how final views are drawn on the screen. You can use a ...
Using NavigationLink programmatically based on binding in SwiftUI
NavigationLink in SwiftUI allows pushing a new destination view on a navigation controller. You can use NavigationLink in a list or decide to push a view programmatically. The latter enables you to trigger a new screen from a different location in your view. Allowing to push a new screen onto ...
Markdown rendering using Text in SwiftUI
SwiftUI comes with built-in markdown support for text, making it easy to transform the text into bold, italic, and other formats. iOS 15 and SwiftUI 3 introduced support taking away the need to combine text weight for similar results. Markdown isn't wholly supported (more on that later), but many features ...