如何清除“行"从SwiftUI中的列表中分离出来? [英] How to remove "row" separators from a List in SwiftUI?

查看:140
本文介绍了如何清除“行"从SwiftUI中的列表中分离出来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从SwiftUI中的List中删除行"分隔符.

I'm trying to remove the "row" separators from a List in SwiftUI.

我已经阅读过List文档,但无法为此找到修饰符.

I went through the List documentation, but I haven't been able to find a modifier for that.

任何帮助将不胜感激.

推荐答案

iOS的SwiftUI List后面有一个UITableView.因此,删除

There is a UITableView behind SwiftUI's List for iOS. So to remove

您需要tableFooterView并删除

您需要separatorStyle成为.none

init() {
    // To remove only extra separators below the list:
    UITableView.appearance().tableFooterView = UIView()

    // To remove all separators including the actual ones:
    UITableView.appearance().separatorStyle = .none
}

var body: some View {
    List {
        Text("Item 1")
        Text("Item 2")
        Text("Item 3")
    }
}

这篇关于如何清除“行"从SwiftUI中的列表中分离出来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆