-
Add custom views and modifiers to the Xcode Library
The Xcode Library is an easy way for you to discover available SwiftUI views and drag and drop them to the Xcode Previews canvas, enabling rich visual editing of your app. We'll show you how to extend the content of the Xcode Library with your own views and modifiers, optimizing for reusability and discoverability within your app or Swift packages.
For more on Xcode Previews, check out "Structure your app for SwiftUI previews", and "Visually edit SwiftUI views".Recursos
Vídeos relacionados
WWDC20
-
Buscar neste vídeo...
-
-
1:57 - LibraryContentProvider
public protocol LibraryContentProvider { @LibraryContentBuilder var views: [LibraryItem] { get } @LibraryContentBuilder public func modifiers(base: ModifierBase) -> [LibraryItem] } -
2:32 - LibraryItem
LibraryItem( SmoothieRowView(smoothie: .lemonberry), visible: true, title: "Smoothie Row View", category: .control ) -
3:22 - LibraryContent
struct LibraryContent: LibraryContentProvider { @LibraryContentBuilder var views: [LibraryItem] { LibraryItem( SmoothieRowView(smoothie: .lemonberry), category: .control ) LibraryItem( SmoothieRowView(smoothie: .lemonberry, showNearbyPopularity: true), title: "Smoothie Row View With Popularity", category: .control ) } } -
8:57 - Image extension
extension Image { func resizedToFill(width: CGFloat, height: CGFloat) -> some View { return self .resizable() .aspectRatio(contentMode: .fill) .frame(width: width, height: height) } } -
9:17 - Modifiers
@LibraryContentBuilder func modifiers(base: Image) -> [LibraryItem] { LibraryItem( base.resizedToFill(width: 100.0, height: 100.0) ) }
-