Skip to content

Declarative Previews!

Compare
Choose a tag to compare
@theoriginalbit theoriginalbit released this 13 Aug 14:37
· 5 commits to main since this release

A rewrite from the ground up, your UIKit previews are now defined from a SwiftUI-inspired DSL.

Replicating a complex in-app design has never been easier, whether the screen you're previewing should show tab bars, large navigation bars, back buttons, toolbars, or all of them at once!

Simply declare how the preview should look…

struct YourViewController_Previews: PreviewProvider {
    static var previews: some View {
        TabBarControllerPreview(selectedIndex: 1) {
            PreviewBlankTabItem(title: "First", symbolNamed: "capsule")
            NavigationControllerPreview(barStyle: .largeTitle, showsToolbar: true) {
                YourViewController()
                YourViewController()
            }
            PreviewBlankTabItem(title: "Third", symbolNamed: "diamond")
        }
        .ignoresSafeArea(.all)
    }
}

…and let PreviewView do the rest

A screenshot of a SwiftUI preview canvas showing a large titled navigation bar with a back arrow, a view controller with a list of items, a toolbar, and a tab bar with 3 tabs