SwiftUI 自定义导航栏

相关Demo

debug custom title view custom title view search
leadingView&trailingView foreground hidden bottom line
background image background linearGradient update background alpha
intercept back event ignore top area

使用方式举例

struct ForegroundView: View {
    var body: some View {
        WRNavigationBar {
            ListView()
        }
        .title("set foreground")
        .foreground(.white)
        .isBackButtonBlack(false)
        .background(Color.blue)
    }
}

相关方法

api description
foreground(_ foreground: Color) foreground
title(_ title: String) 标题(titleView is default)
hiddenLine(_ hidden: Bool) 隐藏底部线
backButtonImageName(_ named: String) 返回按钮图片资源名称
backButtonHidden(_ hidden: Bool) 隐藏返回按钮
isBackButtonBlack(_ isBlack: Bool) 黑色返回按钮(backButton is default)
ignoringTopArea(_ ignore: Bool) 内容忽略导航栏顶部区域
maxWidth(leading: CGFloat = 80, trailing: CGFloat = 80) leadingView 和 trailingView 最大宽度
background<Background>(_ background: Background) background(任意视图)
backButtonTapAction(_ tapAction: @escaping WRBlock) 拦截返回按钮事件( hasBackButton == true)
debug(_ debug: Bool) debug(开启调试)
navigationBarTitleView<Content: View>(@ViewBuilder titleView: () -> Content) titleView(任意视图)
wrNavigationBarItems<Leading: View, Trailing: View>(leading:xx, trailing:xx) 导航栏 leading & trailing 视图
wrNavigationBarItems<Content: View>(@ViewBuilder leading: () -> Content) 导航栏 leading 视图
wrNavigationBarItems<Content>(trailing: () -> Content) 导航栏 trailing 视图

详情地址

https://github.com/wangrui460/SwiftUI-WRNavigationBar

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章