I'm working on a SwiftUI app for tvOS. I have a NavigationLink with an image and a line of text. The item works as expected, when in focus it grows. However, if I change the corner radius (the default is too much), then even though the corner radius is smaller and the image and text grow, the image is clipped (the image grows but its bounds remain the same). How can I fix this?
NavigationStack {
ScrollView {
VStack(alignment: .leading, spacing: 20) {
ForEach(sections) { section in
VStack(alignment: .leading, spacing: 20) {
// Section title
Text(section.title)
.font(.title)
.padding(.horizontal)
// Items
ScrollView(.horizontal) {
LazyHStack(spacing: 50) {
ForEach(section.items) { item in
NavigationLink {
VideoDetailView(mediaItem: item)
} label: {
AsyncImage(url: item.imageURL) { phase in
switch phase {
case .empty:
// This shows while the image is loading
ProgressView()
.aspectRatio(700/500, contentMode: .fit)
.containerRelativeFrame(.horizontal, count: 6, spacing: 50)
case .success(let image):
// This shows the successfully loaded image
image
.resizable()
.aspectRatio(700/500, contentMode: .fit)
.containerRelativeFrame(.horizontal, count: 6, spacing: 50)
case .failure(_):
// This shows if the image fails to load
Image(systemName: "photo")
.resizable()
.aspectRatio(700/500, contentMode: .fit)
.containerRelativeFrame(.horizontal, count: 6, spacing: 50)
@unknown default:
// Any other
EmptyView()
}
} .cornerRadius(5) // WHen I add this, the image gets clipped
Text(item.title)
//Text(item.subtitle)
}
.buttonStyle(.borderless)
}
}
}
.scrollClipDisabled()
}
}
}
}
}

