separatorのことなんですけど、stack flowを見るとできないとか書いてあったんですけど、擬似的に作ることはできるっぽいので記録してみました。

ひとまずそんな機能もモディファイアはないらしい

調べたところ、機能がないんだよねとstack flowに英語で書いてあった。

で、同様のことをできるらしいので、今回はそれを調べてまとめておきました。

小さいRectangleをoverlayで表示するとできるらしい

ひとまず、以下コードを掲載。

Listの中のViewbに対し、listrowInsetsとか、あとはframeでwidthを調整しつつ作ってみました。

struct test_list: View {
    var body: some View {

        List(){
            Text("テキストエリア1")
                .listRowSeparator(.hidden)
                .frame(maxWidth:.infinity,alignment: .leading)
                .listRowInsets(.init(top:0,leading:0,bottom:0,trailing:0))
                .padding(
                    EdgeInsets(
                        top:10,
                        leading: 10,
                        bottom: 10,
                        trailing: 0
                    )
                )
                .overlay(
                    Rectangle()
                        .frame(height: 1)
                        .foregroundColor(.gray),
                    alignment: .bottom
            )
            
            
            Text("テキストエリア1")
                .listRowSeparator(.hidden)
                .frame(maxWidth:.infinity,alignment: .leading)
                .listRowInsets(.init(top:0,leading:0,bottom:0,trailing:0))
                .padding(
                    EdgeInsets(
                        top:10,
                        leading: 10,
                        bottom: 10,
                        trailing: 0
                    )
                )
                .overlay(
                    Rectangle()
                        .frame(height: 1)
                        .foregroundColor(.gray),
                    alignment: .bottom
            )

            
            
            
            
        }
        .listStyle(.plain)
     
        
    }
}

で、できたのがこいつ

まぁ、いったんこれでいこうかなと思ったので、メモしておきました


おわり

コメント