视图的代码如下:
struct ViewDetails: View {
@EnvironmentObject var displayDetails: DisplayDetails
var body: some View {
ScrollView {
GeometryReader { geometry in
ZStack {
if geometry.frame(in: .global).minY <= 0 {
Image("header")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: geometry.size.width, height: geometry.size.height)
.offset(y: geometry.frame(in: .global).minY/9)
.clipped()
} else {
Image("header")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: geometry.size.width, height: geometry.size.height + geometry.frame(in: .global).minY)
.clipped()
.offset(y: -geometry.frame(in: .global).minY)
}
}
}.frame(height: 400)
VStack(alignment: .leading) {
HStack {
Image("author")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 60, height: 60)
.clipped()
.cornerRadius(10)
VStack(alignment: .leading) {
Text("Article by")
.font(.custom("AvenirNext-Regular", size: 15))
.foregroundColor(.gray)
Text("John Doe")
.font(.custom("AvenirNext-Demibold", size: 15))
}
}.padding(.top, 20)
Text("Lorem ipsum dolor sit amet")
.font(.custom("AvenirNext-Bold", size: 30))
.lineLimit(nil)
.padding(.top, 10)
Text("3 min read • 22. November 2019")
.font(.custom("AvenirNext-Regular", size: 15))
.foregroundColor(.gray)
.padding(.top, 10)
Text(articleContent)
.font(.custom("AvenirNext-Regular", size: 20))
.lineLimit(nil)
.padding(.top, 30)
}
.frame(width: 350)
}
.edgesIgnoringSafeArea(.all)
.onAppear(perform: {
self.displayDetails.showFullScreen.toggle()
})
}
}
所以我不确定我是否可以删除底部显示为灰色/白色的任何内容,或者我是否可以更改它的颜色,无论哪种方式都适合我,但我无法实现它!?任何人都可以帮忙。