UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How do I get sidebar icons to use the accent color?

Forums > SwiftUI

For an iPad app I am developing I have created a sidebar. Although the sidebar is visible and uses the specified accent color when selecting an item in the list, it fails to display the icons in the accent color. See attached code below. Does anyone have an idea what I am missing here?

(Xcode 12.2 Beta 3)

        List(selection: $selection) {
            NavigationLink(
                destination: HomeView()) {
                Label("Home", systemImage: "house.fill")
            }
            .tag(NavigationItem.home)

            NavigationLink(
                destination: TimelineView()) {
                Label("Timeline", systemImage: "calendar")
            }
            .tag(NavigationItem.home)

            // More of the same...

        }
        .listStyle(SidebarListStyle())
        .navigationTitle("Sidebar Menu")

3      

@Cifer  

Same issue.

You didn't missing anything, so did I.

It's just bugged. 🤣

It's very strange, and my Xcode version is 12.2 (12B45b).

2      

I might be wrong here, but did you try adding the color to the label directly?

2      

The behaviour of labels within sidebar lists has been changed a number of times by Apple in the different versions of iOS 14. There is nothing wrong with your code, and I have found this in my app too.

The code you have posted has the following behaviours depending on which version of iPadOS 14 you are running on your device:

  • iPadOS 14.0: Label icons are in the accent colour
  • iPadOS 14.2: Label icons are black (light mode) or white (dark mode) — the same colour as text
  • iPadOS 14.3 (Beta): Label icons are in the accent colour AND section titles are in the accent colour.

Even the new behaviour in the iPadOS 14.3 Beta seems out of place, as other system apps (e.g. Music, Mail) have section names in black/white. Hopefully Apple will make it more consistent soon.

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.