SwiftUI實(shí)戰(zhàn)系列
- SwiftUI實(shí)戰(zhàn)-使用ViewModifier自定義微信TabBar底部導(dǎo)航和NavigationView
- SwiftUI實(shí)戰(zhàn)-NavigationLink圖片和文字顯示藍(lán)色或者圖片無(wú)顯示
- SwiftUI實(shí)戰(zhàn)-去除List分割線
- SwiftUI實(shí)戰(zhàn)-自定義彈窗
- SwiftUI實(shí)戰(zhàn)-自定義加載指示器HUD
- SwiftUI實(shí)戰(zhàn)-廣告頁(yè)踱侣、歡迎頁(yè)
- SwiftUI實(shí)戰(zhàn)-NavigationView + TabView基本框架搭建
- SwiftUI實(shí)戰(zhàn)-Pager分頁(yè)查看器
- SwiftUI實(shí)戰(zhàn)-隱私政策和用戶協(xié)議彈窗
- SwiftUI實(shí)戰(zhàn)-多圖粪小、大圖圖片瀏覽
- SwiftUI實(shí)戰(zhàn)-下拉菜單
- SwiftUI實(shí)戰(zhàn)-系統(tǒng)NavigationView自定義titleView
- SwiftUI實(shí)戰(zhàn)-WKWebView的使用
- SwiftUI實(shí)戰(zhàn)-自定義轉(zhuǎn)圈指示器
- SwiftUI實(shí)戰(zhàn)-自定義TextField搭建登錄頁(yè)面UI
- SwiftUI實(shí)戰(zhàn)-自定義底部彈窗
- SwiftUI實(shí)戰(zhàn)-顯示星級(jí)評(píng)分
- SwiftUI實(shí)戰(zhàn)-類似新聞?lì)^條輪播滾動(dòng)
- SwiftUI實(shí)戰(zhàn)-仿用戶協(xié)議確認(rèn)頁(yè)面支持點(diǎn)擊文字顯示協(xié)議
- SwiftUI實(shí)戰(zhàn)-新特性、新版本介紹
- SwiftUI實(shí)戰(zhàn)-多圖選擇抡句、圖片選擇器
- SwiftUI實(shí)戰(zhàn)-輪播圖
- SwiftUI實(shí)戰(zhàn)-網(wǎng)絡(luò)請(qǐng)求工具封裝
- SwiftUI實(shí)戰(zhàn)-多級(jí)聯(lián)動(dòng)地址選擇
- SwiftUI實(shí)戰(zhàn)-使用UIActivityIndicatorView
- SwiftUI實(shí)戰(zhàn)-Expanded可伸縮的分組列表List
- SwiftUI實(shí)戰(zhàn)-滾動(dòng)列表內(nèi)容返回頂部探膊、底部、指定位置
- SwiftUI實(shí)戰(zhàn)-List列表內(nèi)容動(dòng)態(tài)改變更新
- SwiftUI-繪制氣泡圖
- SwiftUI-仿微信加號(hào)Popover氣泡彈窗
- SwiftUI實(shí)戰(zhàn)-單邊圓角單個(gè)圓角
本章內(nèi)容
系統(tǒng)NavigationView自定義titleView
效果圖:
相關(guān)源碼:
ContentView.swift
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
VStack(spacing: 20) {
NavigationLink(destination: Page2()) {
Text("Page 2")
}
NavigationLink(destination: Search()) {
Text("Search")
}
}
.navigationBarTitleView(displayMode: .inline) { Text("Page 1").foregroundColor(.orange) }
}
}
}
struct Page2: View {
var body: some View {
Text("Page 2")
.navigationBarTitleView(displayMode: .inline) { Text("Page 2").foregroundColor(.blue) }
}
}
struct Search: View {
@State var term = ""
var body: some View {
Text("Page 2")
.navigationBarTitleView(displayMode: .inline) { TextField("Search", text: $term) }
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
NavigationTitleView.swift