2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【SwiftUI】Listのセパレーターの長さを調節する

Last updated at Posted at 2023-07-24

はじめに

セパレーターの長さを変更する方法を調べたので記事にしました。

サンプルアプリ

ランダムでセパレーターの長さを設定しています
simulator_screenshot_DDE335AF-F694-41E8-944F-9BDF1A4D68BD.png

実装

import SwiftUI

struct ContentView: View {
    var body: some View {
        List {
            ForEach(0..<50) { _ in
                Text("テスト")
+                   .alignmentGuide(.listRowSeparatorLeading) { viewDimensions in
+                       return CGFloat.random(in: 0.0...100.0)
+                   }
            }
        }
    }
}

おわり

UIKitでいうseparatorInsetですね

参考記事

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?