I created a view for card. But whenever I try to add 20px spacing between first text (Heading) and middle text (description) limit to 3 lines and button, the middle text automatically truncated. I used bottom padding but same.
I want button position should not be changed and middle text limit I set to 3 lines.
How can I add spacing with static position of button? Many thanks for help.
Code:
struct CardView: View {
// MARK: - Constants
private struct ViewConstants {
static let screenWidth = UIScreen.main.bounds.width
static let cardWidth = screenWidth - 100
static let cardRatio = 300.0/377.0
static let cardHeight = cardWidth/cardRatio + 10
}
var body: some View {
ZStack {
VStack(spacing: 8) {
LottieView(filename: "Animation", animationType: .loop)
.frame(height: ViewConstants.cardHeight / 2)
VStack {
Text("CARD SHOPPING")
.font(.system(size: 18))
.lineLimit(1)
.padding(.bottom, 2)
Text("The all-in-one solution to buy all the smartphones, laptops and tablets in your house. Many ")
.lineLimit(3)
.padding(.horizontal, 24)
}
Button(action: {
print("sign up bin tapped")
}) {
Text("Click for more")
.font(.system(size: 14))
.padding()
.foregroundColor(.black)
.overlay(
RoundedRectangle(cornerRadius: 25)
.stroke(Color.black, lineWidth: 2)
)
}
.padding(.top, 4)
.padding(.bottom, 24)
}
.frame(width: ViewConstants.cardWidth, height: ViewConstants.cardHeight)
.multilineTextAlignment(.center)
.background(Color.yellow)
.cornerRadius(12)
}
.padding(.leading, -20 * 3)
}
}
Image:
need spacing