swift - 如何在 SwiftUI 中圆角并减小列表的大小?
问题描述
我想减小 List 的宽度并使其圆角。
我已经尝试过 .cornerRadius() 和 frame(width:) 修饰符,但它对我不起作用。
解决方案
你可以试试
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)
}
}
推荐阅读
- python - 将多个重复的模式名称分配给列表值
- python - 如何将导出的文件保存到与py文件相同的路径并将我的csv文件重命名为文件夹名称
- javascript - 在将浏览器窗口大小调整为全屏时,将网格项目调整为之前的状态
- python - scipy.optimize 使用动态多变量列表最小化
- node.js - nodejs azure web app给出http 431错误
- selenium-webdriver - Webdriver:在调用 addCookie 方法后,浏览器使用 Dot 设置域
- python - 试图将我的收入报告写入 .txt 文件
- amazon-web-services - 如何使用 go sdk 在 aws EC2 中自动执行脚本?
- windows-subsystem-for-linux - 如何在 WSL 和 Windows10 中组织编程语言和库
- python - 在列中平均分配重复的时间戳