SwiftUI RoundedRectangle cutting off on the bottom

Viewed 204

I have a swift RoundedRectangle:

ScrollView(.horizontal, showsIndicators: false) {
            Group {
                HStack {
                    if let height = height {
                        if height != "" {
                            aboutMeItem(info: height, image: "ruler").frame(minWidth: 20)
                        }
                    }
                }
                .frame(minHeight: 70, maxHeight: 70)
                .overlay(RoundedRectangle(cornerRadius: 15).stroke(Color("darkGrey"), lineWidth: 3))
                .padding([.leading,.top,.trailing])
            }
        }

My output is:

enter image description here

For some reason the bottom line is being slightly cut out and you cant see the full line width.

Iv tried removing the view below it incase something was covering it but that wasn't it. I've tried messing with the frame min and maxHeight, but thats still the same regardless of the same.

1 Answers

You should use strokeBorder instead of stroke.

another thing that you done was .padding([.leading,.top,.trailing]) so you did not include bottom! but I think strokeBorder would cover that as well.


ScrollView(.horizontal, showsIndicators: false) {
        Group {
            HStack {
                if let height = height {
                    if height != "" {
                        aboutMeItem(info: height, image: "ruler").frame(minWidth: 20)
                    }
                }
            }
            .frame(minHeight: 70, maxHeight: 70)
            .overlay(RoundedRectangle(cornerRadius: 15).strokeBorder(Color("darkGrey"), lineWidth: 3)) // <<: Here
            .padding([.leading,.top,.trailing]) // <<: Here!!! you did not used .bottom
        }
    }
Related