Runt
2025-06-27 5e101b6d445d9bbff119d308c454c55d0a03de14
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
//
//  TitleBarView.swift
//  aones
//
//  Created by 倪路朋 on 2/16/23.
//
 
import SwiftUI
 
struct TitleBarView: View {
    
    @Environment(\.presentationMode) var presentationMode
    
    var title = ""
    var imgLeft = "IconBack";
    var imgRight = "";
    var titleColor = "ColorText"
    
    var body: some View {
        
            HStack(spacing: 0){
                Spacer().frame(width: 16)
                Button(action: {
                    print("Click back button")
                    self.presentationMode.wrappedValue.dismiss()
                }) {
                    Image(imgLeft)
                        .frame(width: 28,height: 28)
                }
                Spacer()
                Text(title).foregroundColor(Color.init(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: "标题")
    }
}