简体   繁体   中英

Change of listRowBackground in SwiftUI for NavigationLink doesn't change the full background

Code is the following:

List(selection: $selectedBoard) {
    ForEach(boards) { board in
        NavigationLink(tag: board, selection: $selectedBoard) {
            BoardView(board: board)
        } label: {
            Text(board.name ?? "Board")
         }
        .listRowBackground(self.selectedBoard == board ? Color.App.boardSelection : Color.App.boardBackground)

The effect is the following:

在此处输入图像描述

See the gray space on the left and right? This is the accent color that I don't know how to remove. The whole row should be the same, uniform color of a bit lighter black.

Working example: https://github.com/igr/Clmn

https://github.com/igr/Clmn/blob/main/Clmn/Views/BoardList/BoardsNavigationListView.swift#L32

This happens when List is used in NavigationView for iteration of NavigationLink elements.

This seems to be a bug.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM