I want to scale my image to the full size of my view. I tried the solutions from this post: How to resize Image but I still did not manage to get it to work the right way.
It has the right padding to the top, left and right. But it does not have a padding to the random prize button like in the design I am trying to recreate.
Now this is almost perfect but I want it to have less padding to the left and right side.
This is my current Code for the main View:
GeometryReader { proxy in
let width = proxy.size.width
let height = proxy.size.height
VStack(spacing: 0) {
TopBarView()
VStack {
ZStack { ForEach(cards.reversed()) { card in
ImageCard(card)
}
}
}
}.padding(.top, 8)
.padding(.leading, 12)
.padding(.trailing, 12)
.padding(.bottom, 16)
HStack {
// Random prize Button
}.cornerRadius(6)
.padding(12)
HStack {
Button() {
} label: {
//Red Cross Button
}.frame(width: width * (32 / 100), height: width * (32 / 100))
.cornerRadius(100)
Spacer()
Button() {
} label: {
// eye Button
}.frame(width: width * (19.733 / 100), height: width * (19.733 / 100))
.cornerRadius(50)
Spacer()
Button() {
} label: {
// Checked Button
}.frame(width: width * (32 / 100), height: width * (32 / 100))
.cornerRadius(100)
}.frame(width: width - 24)
.padding(.leading, 12)
.padding(.trailing, 12)
}
}
This is the ImageCard View:
VStack(alignment: .center) {
card.image
.resizable()
.cornerRadius(8)
.scaledToFill()
}.frame(maxWidth: .infinity, maxHeight: .infinity)