簡體   English   中英

SwiftUI 圓角矩形底部切掉

[英]SwiftUI RoundedRectangle cutting off on the bottom

我有一個 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])
            }
        }

我的 output 是:

在此處輸入圖像描述

由於某種原因,底線被略微切掉,您看不到完整的線寬。

Iv 嘗試刪除它下面的視圖,以防有東西覆蓋它,但事實並非如此。 我試過弄亂frame minmaxHeight ,但無論如何都一樣。

您應該使用strokeBorder而不是stroke

你做的另一件事是.padding([.leading,.top,.trailing])所以你沒有包括底部! 但我認為strokeBorder也會涵蓋這一點。


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
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM