Introspect allows you to get the underlying UIKit or AppKit element of a SwiftUI view.
For instance, with Introspect you can access
UITableView to modify separators, or
UINavigationController to customize the tab bar.
How SwiftUI Introspect works
Introspect works by adding a custom
IntrospectionView to the view hierarchy, then looking into the UIKit hierarchy to find the relevant view.
For instance, when introspecting a
TextField, it will:
IntrospectionViewas an overlay of
- Get the view host of the introspection view (which is alongside the view host of the
- Get the previous sibling containing
Please note that this introspection method might break in future SwiftUI releases. Future implementations might not use the same hierarchy, or might not use UIKit elements that are being looked for. Though the library is unlikely to crash, the
.introspect() method will not be called in those cases.
Usage in production
Introspect is meant to be used in production. It does not use any private API. It only inspects the view hierarchy using publicly available methods. The library takes a defensive approach to inspecting the view hierarchy: there is no hard assumption that elements are laid out a certain way, there is no force-cast to UIKit classes, and the
introspect() methods are simply ignored if UIKit views cannot be found.
Mobile App Development Best Practices – 28.09
iOS Decodable CoreData: A Proof-of-Concept for Building Offline-First iOS Apps The Future of Accessing User Location in SwiftUI Create SPM...
What is Dependency Injection
The primary goal of dependency injection is to reduce the coupling between components by removing the dependency resolution responsibility from...
Dependency Management in a Multi-Module Project – THIS Is How You Need to Do It
⭐ Learn how to make apps scale with a multi-module architecture.
Raspberry Pi 5 microcomputer unveiled
At launch, the Raspberry Pi 5 will come with several RAM options: $60 for the 4GB version and $80 for...
Cashew – Personal finances on Flutter
Cashew is a full-fledged, feature-rich application designed to empower users in managing their finances effectively. Built using Flutter – with...
Mobile App Development Best Practices – 27.09
Swipe Actions from Scratch, Effective code reviews for Android developers, WebP exploit and more!