首页 > 解决方案 > 如何在 SwiftUI 中圆角并减小列表的大小?

问题描述

我想减小 List 的宽度并使其圆角。

我已经尝试过 .cornerRadius() 和 frame(width:) 修饰符,但它对我不起作用。

标签: swiftxcodeswiftuixcode11ios13

解决方案


你可以试试

struct ContentView : View {
    var body: some View {
        List{
             Text("Hello World").listRowBackground(Color.green)
             Text("Hello World").listRowBackground(Color.green)
             Text("Hello World").listRowBackground(Color.green)
             Text("Hello World").listRowBackground(Color.green)
        }.cornerRadius(30).frame(width: 200, height:200, alignment: .center)
    }
}

推荐阅读