Search code examples
listviewscrollscrollviewswiftuitvos

How to make a SwiftUI list scrollable in tvOS


I have a List with content and when I build to an Apple Tv I cannot scroll to the bottom of the List.

I tried the focusable on the List rows but I cannot seem to get the list to scroll. I also replaced the List with a ScrollView to no avail.

List(self.someData) { data in
     SomeListRow(data: data)
}
.shadow(radius: 5)
.focusable(true)

List(self.someData) { data in
     SomeListRow(data: data)
      .focusable(true)

}
.shadow(radius: 5)

Solution

  • SwiftUI on tvOS has a bug where if you set a shadow on something none of the components in it receive user input events such as focus. There's an easy workaround though, just set your shadow on the background layer.

    .background(
        Color.white
            .shadow(radius: 5)
    )