English 中文(简体)
消除边界底层一线
原标题:remove bottom side of border around view
  • 时间:2024-02-05 02:28:28
  •  标签:
  • swiftui

I want to draw a shape where the bottom side of the border is removed, so we can see the background.

struct SwiftUIView: View {
    var body: some View {
        Text("Hello World!")
            .padding(10.0)
            .border(Color.blue, width: 3.0)
            .cornerRadius(4.0)
    }
}

“entergraph

我不敢做到这一点。 我看着粉碎和沙皮,但并不确切地确定最佳办法是什么。

问题回答

我认为,这样做的最容易的方法是添加“条码”(>中继<>>/条码>,与底线一致,而不是使用<条码>。 您不妨尝试这一做法:

Text("Hello World!")
    .padding(10.0)
    .border(Color.blue, width: 3.0)
    .cornerRadius(4.0)
    .overlay(alignment: .bottom) { //<- here
        Rectangle()
            .foregroundColor(.white)
            .frame(height: 3) //<- height should be equal to borderWidth above
    }

“在此处的影像描述”/</a





相关问题
SwiftUI: How do I position a button x points above a sheet?

I am trying to recreate a Maps-style UI with a persistent bottom sheet and controls fixed above. Apple Maps UI with controls above ☝️ Example here, the "Look Around" binoculars button and ...

How to access own window within SwiftUI view?

The goal is to have easy access to hosting window at any level of SwiftUI view hierarchy. The purpose might be different - close the window, resign first responder, replace root view or ...

热门标签