小编ani*_*an9的帖子

HStack 和 TextField 的角半径未更新

这是我的内容视图的代码。正如您所看到的,我尝试了使用 HStack 来包含 TextField,以及仅包含 TextField 本身。角半径对灰色搜索矩形没有任何影响 - 边缘仍然是完美的矩形。

    
    @State var searchText = ""
    var body: some View {
        ZStack {
            //function that's the content argument to ZStack
            Color((.systemGreen))
            VStack {
                Text("App")
                    .font(.largeTitle)
                    .foregroundColor(Color.white)
                //HStack {
                TextField("Searchstring", text: $searchText)
                    .padding()
                    .background(Color(.systemGray6))
                    .padding()
                    .cornerRadius(12)
                //}
//                .padding()
//                .background(Color(.systemGray6))
//                .padding(.horizontal)
//                .cornerRadius(12)
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在所有情况下,预览都是这样的: 角半径无法在预览中显示

swift swiftui contentview

2
推荐指数
1
解决办法
2839
查看次数

标签 统计

contentview ×1

swift ×1

swiftui ×1