I am trying to build a screen similar to the following.
But there are few things that are wrong with this screen:
- The image and the text below it are not exactly the same width. The image is slightly wider.
- The image and its associated text overlap the text above it.
- The text underneath the image is truncated.
I've been on this for two days with no luck! Can someone provide feedback on how I can achieve this? Below is what I have in terms of code.
struct ImageTitleTileView: View {
var body: some View {
GeometryReader { geometry in
VStack(spacing: 0) {
Image("image")
.resizable()
.frame(width: geometry.size.width)
.aspectRatio(1, contentMode: .fill)
Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.")
.padding()
.background(Color.white)
}
.edgesIgnoringSafeArea(.all)
}.aspectRatio(contentMode: .fit)
}
}
struct MainItemView: View {
var body: some View {
ZStack {
Color(.whiteSmoke)
VStack(spacing: 10) {
Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.")
ImageTitleTileView()
}.padding(16)
}
}
}