让这段代码成为 swiftui 项目的主要视图之一。
这是页面的截图:我想知道如何提升我在 Trips.swift 中的 hstack,以便 Trips 标签更靠近顶部个人资料页面 https://imgur.com/GgFMStG
struct ProfileHome: View {
var profile: UserProfile
let date : Date
let dateFormatter : DateFormatter
var demoData = trips
var offsetValue = -150
init() {
profile = UserProfile(userName: "Sexiest Boy")
date = Date()
dateFormatter = DateFormatter()
dateFormatter.dateStyle = .long
dateFormatter.timeStyle = .short
}
var body: some View {
NavigationView {
VStack(){
Image("defaultProfile").resizable().aspectRatio(contentMode: .fill)
.frame(width: 300.0, height: 300.0, alignment: .top).clipShape(Circle())
.shadow(radius: 10)
.overlay(Circle().stroke(Color.blue, lineWidth: 5))
.offset(y: CGFloat(offsetValue))
Text(profile.userName)
.offset(y: CGFloat(offsetValue))
Text(date, formatter: dateFormatter).offset(y: CGFloat(offsetValue))
TabView {
Trips(items: demoData)
.tabItem {
Label("Trips", systemImage: "photo.on.rectangle.angled")
}
Stats()
.tabItem {
Label("Stats", systemImage: "photo.on.rectangle.angled")
}
Friends()
.tabItem {
Label("Friends", systemImage: "photo.on.rectangle.angled")
}
}
Spacer()
//end vstack
}
}
}
}