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

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