View

extension View
  • 配置导航栏SwiftUI左侧、标题、右侧视图和背景

    Declaration

    Swift

    public func navigationBarConfigure<Leading: View, Title: View, Trailing: View>(
        leading: Leading,
        title: Title,
        trailing: Trailing,
        background: Color? = nil
    ) -> some View
  • 配置导航栏SwiftUI左侧、标题视图和背景

    Declaration

    Swift

    public func navigationBarConfigure<Leading: View, Title: View>(
        leading: Leading,
        title: Title,
        background: Color? = nil
    ) -> some View
  • 配置导航栏SwiftUI标题视图和背景

    Declaration

    Swift

    public func navigationBarConfigure<Title: View>(
        title: Title,
        background: Color? = nil
    ) -> some View
  • 配置导航栏SwiftUI标题、右侧视图和背景

    Declaration

    Swift

    public func navigationBarConfigure<Title: View, Trailing: View>(
        title: Title,
        trailing: Trailing,
        background: Color? = nil
    ) -> some View
  • 配置导航栏左侧、标题、右侧按钮和背景,兼容AnyView和UIKit对象

    Declaration

    Swift

    public func navigationBarConfigure(
        leading: Any?,
        title: Any?,
        trailing: Any? = nil,
        background: Any? = nil
    ) -> some View
  • 配置当前导航栏

    Declaration

    Swift

    public func navigationBarConfigure(
        _ configuration: NavigationBarConfiguration
    ) -> some View
  • 配置当前顶部视图控制器

    Declaration

    Swift

    public func viewControllerConfigure(
        _ configuration: @escaping (UIViewController) -> ()
    ) -> some View
  • 配置当前SwiftUI视图对应UIView。仅适用于有对应UIView的视图(如Text等),不支持Layer视图(如VStack等)

    Declaration

    Swift

    public func hostingViewConfigure(
        _ configuration: @escaping (UIView) -> ()
    ) -> some View

View+HostingView

  • 快速包装到HostingView

    Declaration

    Swift

    public func wrappedHostingView() -> HostingView<AnyView>
  • 设置视图上下文,可指定自定义对象

    Declaration

    Swift

    public func viewContext(_ viewController: UIViewController?, object: Any? = nil) -> some View
  • 设置视图上下文,可指定自定义对象和用户信息

    Declaration

    Swift

    public func viewContext(_ viewController: UIViewController?, object: Any? = nil, userInfo: [AnyHashable : Any]?) -> some View
  • 转换视图上下文,内部可使用DispatchQueue.main.async执行异步方法

    如果要监听上下文变化,可使用如下方式:

    1. onReceive(viewContext.subject)
    2. onReceive(viewContext.$object)
    3. viewContext.$object.receive(on: RunLoop.main)

    Declaration

    Swift

    public func transformViewContext(transform: @escaping (ViewContext) -> Void) -> some View
  • 快速包装视图到上下文控制器

    Declaration

    Swift

    public func wrappedContextController() -> UIHostingController<AnyView>

ViewExtensions

  • Undocumented

    Declaration

    Swift

    public func inject<SomeView>(_ view: SomeView) -> some View where SomeView : View
  • Finds a TargetView from a SwiftUI.View

    Declaration

    Swift

    public func introspect<TargetView: UIView>(
        selector: @escaping (IntrospectionUIView) -> TargetView?,
        customize: @escaping (TargetView) -> ()
    ) -> some View
  • Finds a UINavigationController from any view embedded in a SwiftUI.NavigationView.

    Declaration

    Swift

    public func introspectNavigationController(customize: @escaping (UINavigationController) -> ()) -> some View
  • Finds a UISplitViewController from a SwiftUI.NavigationView with style DoubleColumnNavigationViewStyle.

    Declaration

    Swift

    public func introspectSplitViewController(customize: @escaping (UISplitViewController) -> ()) -> some View
  • Finds the containing UIViewController of a SwiftUI view.

    Declaration

    Swift

    public func introspectViewController(customize: @escaping (UIViewController) -> ()) -> some View
  • Finds a UITabBarController from any SwiftUI view embedded in a SwiftUI.TabView

    Declaration

    Swift

    public func introspectTabBarController(customize: @escaping (UITabBarController) -> ()) -> some View
  • Finds a UITableView from a SwiftUI.List, or SwiftUI.List child.

    Declaration

    Swift

    public func introspectTableView(customize: @escaping (UITableView) -> ()) -> some View
  • Finds a UITableViewCell from a SwiftUI.List, or SwiftUI.List child. You can attach this directly to the element inside the list.

    Declaration

    Swift

    public func introspectTableViewCell(customize: @escaping (UITableViewCell) -> ()) -> some View
  • Finds a UIScrollView from a SwiftUI.ScrollView, or SwiftUI.ScrollView child.

    Declaration

    Swift

    public func introspectScrollView(customize: @escaping (UIScrollView) -> ()) -> some View
  • Finds the horizontal UIScrollView from a SwiftUI.TabBarView with tab style SwiftUI.PageTabViewStyle.

    Customize is called with a UICollectionView wrapper, and the horizontal UIScrollView.

    Declaration

    Swift

    @available(iOS 14.0, tvOS 14.0, watchOS 7.0, *)
    @available(macOS, unavailable)
    public func introspectPagedTabView(customize: @escaping (UICollectionView, UIScrollView) -> ()) -> some View
  • Finds a UITextField from a SwiftUI.TextField

    Declaration

    Swift

    public func introspectTextField(customize: @escaping (UITextField) -> ()) -> some View
  • Finds a UITextView from a SwiftUI.TextEditor

    Declaration

    Swift

    public func introspectTextView(customize: @escaping (UITextView) -> ()) -> some View
  • Finds a UISwitch from a SwiftUI.Toggle

    Declaration

    Swift

    @available(tvOS, unavailable)
    public func introspectSwitch(customize: @escaping (UISwitch) -> ()) -> some View
  • Finds a UISlider from a SwiftUI.Slider

    Declaration

    Swift

    @available(tvOS, unavailable)
    public func introspectSlider(customize: @escaping (UISlider) -> ()) -> some View
  • Finds a UIStepper from a SwiftUI.Stepper

    Declaration

    Swift

    @available(tvOS, unavailable)
    public func introspectStepper(customize: @escaping (UIStepper) -> ()) -> some View
  • Finds a UIDatePicker from a SwiftUI.DatePicker

    Declaration

    Swift

    @available(tvOS, unavailable)
    public func introspectDatePicker(customize: @escaping (UIDatePicker) -> ()) -> some View
  • Finds a UISegmentedControl from a SwiftUI.Picker with style SegmentedPickerStyle

    Declaration

    Swift

    public func introspectSegmentedControl(customize: @escaping (UISegmentedControl) -> ()) -> some View
  • Finds a UIColorWell from a SwiftUI.ColorPicker

    Declaration

    Swift

    @available(iOS 14.0, *)
    @available(tvOS, unavailable)
    public func introspectColorWell(customize: @escaping (UIColorWell) -> ()) -> some View

ViewSizePreferenceKey

  • 捕获当前视图大小

    Declaration

    Swift

    public func captureSize(in binding: Binding<CGSize>) -> some View

ViewContentOffsetPreferenceKey

  • 捕获当前滚动视图内容偏移,需滚动视图调用,且用GeometryReader包裹滚动视图

    使用示例: GeometryReader { proxy in List { … } .captureContentOffset(in: $contentOffsets) }

    Declaration

    Swift

    public func captureContentOffset(in binding: Binding<CGPoint>) -> some View
  • 捕获当前滚动视图内容偏移,需滚动视图第一个子视图调用

    使用示例: GeometryReader { proxy in List { Cell .captureContentOffset(proxy: proxy)

      ...
    }
    .captureContentOffset(in: $contentOffsets)
    

    }

    Declaration

    Swift

    public func captureContentOffset(proxy outsideProxy: GeometryProxy) -> some View

Plugin

  • 显示通用控制器插件,自动切换

    Declaration

    Swift

    public func showPlugin(_ isShowing: Binding<Bool>, customize: @escaping (UIViewController) -> Void) -> some View
  • 显示控制器弹窗插件,自动切换

    Declaration

    Swift

    public func showAlert(_ isShowing: Binding<Bool>, customize: @escaping (UIViewController) -> Void) -> some View
  • 显示控制器消息吐司插件,自动切换

    Declaration

    Swift

    public func showToast(_ isShowing: Binding<Bool>, customize: @escaping (UIViewController) -> Void) -> some View
  • 显示控制器空界面插件,需手工切换

    Declaration

    Swift

    public func showEmpty(_ isShowing: Bool, customize: ((UIViewController) -> Void)? = nil) -> some View
  • 显示控制器加载吐司插件,需手工切换

    Declaration

    Swift

    public func showLoading(_ isShowing: Bool, customize: ((UIViewController) -> Void)? = nil) -> some View
  • 显示控制器进度吐司插件,需手工切换

    Declaration

    Swift

    public func showProgress(_ isShowing: Bool, customize: @escaping (UIViewController) -> Void) -> some View

PluginView

  • 显示通用插件视图,需手工切换

    Declaration

    Swift

    public func showPluginView<Plugin: View>(
        _ isShowing: Bool = true,
        @ViewBuilder builder: @escaping () -> Plugin
    ) -> some View
  • 显示空界面插件视图,需手工切换

    Declaration

    Swift

    public func showEmptyView(
        _ isShowing: Bool = true,
        builder: (() -> EmptyPluginView)? = nil
    ) -> some View
  • 显示加载插件视图,需手工切换

    Declaration

    Swift

    public func showLoadingView(
        _ isShowing: Bool = true,
        builder: (() -> LoadingPluginView)? = nil
    ) -> some View
  • 显示进度插件视图,需手工切换

    Declaration

    Swift

    public func showProgressView(
        _ isShowing: Bool = true,
        builder: @escaping () -> ProgressPluginView
    ) -> some View

View+Toolkit

  • 设置不规则圆角效果

    Declaration

    Swift

    public func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View
  • 同时设置边框和圆角

    Declaration

    Swift

    public func border<S>(_ content: S, width lineWidth: CGFloat = 1, cornerRadius: CGFloat) -> some View where S : ShapeStyle
  • 切换视图移除性

    Declaration

    Swift

    public func removable(_ removable: Bool) -> some View
  • 切换视图隐藏性

    Declaration

    Swift

    public func hidden(_ isHidden: Bool) -> some View
  • 切换视图可见性

    Declaration

    Swift

    public func visible(_ isVisible: Bool = true) -> some View
  • 动态切换裁剪性

    Declaration

    Swift

    public func clipped(_ value: Bool) -> some View
  • 条件成立时执行下一步

    Declaration

    Swift

    public func then<T>(_ condition: Bool, body: (Self) -> T) -> some View where T : View
  • 配置当前对象

    Declaration

    Swift

    public func configure(_ body: (inout Self) -> Void) -> Self
  • 转换为AnyView

    Declaration

    Swift

    public func eraseToAnyView() -> AnyView