1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
//  TitleBarView.swift
//  aones
//
//  Created by 倪路朋 on 2/16/23.
//
 
import SwiftUI
 
struct TitleBarView: View {
    
    @Environment(\.presentationMode) var presentationMode
    
    var title = ""
    var iconBack  = Icons.BACK;
    var imgRight = "";
    var titleColor = Color.colorText
    
    var body: some View {
        
            HStack(spacing: 0){
                Spacer().frame(width: 16)
                Button(action: {
                    print("Click back button")
                    self.presentationMode.wrappedValue.dismiss()
                }) {
                    Image(systemName: iconBack.name)
                        .resizable()
                        .frame(width: iconBack.size.width, height: iconBack.size.height)
                        .aspectRatio(contentMode: .fit)
                        .foregroundColor(Color.white)
                }
                Spacer()
                Text(title).foregroundColor(titleColor)
                    .bold().font(Font.system(size: 16))
                Spacer()
                Image(imgRight).frame(width: 28,height: 28)
                Spacer().frame(width: 16)
            }.frame(height: 48)
    }
}
 
struct TitleBarView_Previews: PreviewProvider {
    static var previews: some View {
        TitleBarView(title: "标题")
    }
}