我正在尝试实现 iOS 设置应用程序或 Roborock 应用程序中也可以看到的行为(请参见下面的屏幕截图)。我想要一个图标,然后为行分隔符添加一个插图。
我已经尝试过:
UITableView.appearance().separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 80)
但这不适用于 SwiftUI 3.0 / iOS 15.1
这是完整的代码:
import SwiftUI
struct ListTest: View {
var body: some View {
List {
Button(action: {
print("Test")
}) {
SettingsCell2(title: "Test", iconName: "bell.badge.fill")
}
Button(action: {
print("Test")
}) {
SettingsCell2(title: "Test", iconName: "bell.badge.fill")
}
}
}
}
struct SettingsCell2: View {
var title : String
var iconName : String
var body: some View {
HStack {
ZStack {
RoundedRectangle(cornerRadius: 8, style: .continuous)
.fill(Color.red)
Image(systemName: iconName)
.foregroundColor(.white)
}
.frame(width: 30, height: 30, alignment: .center)
Text(title)
.foregroundColor(.primary)
Spacer()
Image(systemName: "chevron.right")
.font(.headline)
.foregroundColor(.gray)
}
}
}
struct ListTest_Previews: PreviewProvider {
static var previews: some View {
ListTest()
}
}
有什么想法可以实现这一点吗?
Xcode 14 / iOS 16
其实一切都是需要的.listStyle(.insetGrouped)
更多细节是here
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)