0
override func viewWillAppear(_ animated: Bool)
{        
    if let colorHex = selectedCategory?.color
    {        
        title = selectedCategory?.name
            
        guard let navBar = navigationController?.navigationBar.scrollEdgeAppearance else 
        {
            fatalError("Navigation Controller does not exist")
        }
            
        if let navBarColor = UIColor(hexString: colorHex)
        {
            navBar.backgroundColor = navBarColor

            // ERROR IN THIS LINE-Reference to member 'tintColor'
            // cannot be resolved without a contextual type
            navBar.buttonAppearance = [.tintColor:navBarColor] 

            navBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : ContrastColorOf(navBarColor, returnFlat: true)]
            searchBar.barTintColor = navBarColor
        }
    }
}

I'm getting an error on navBar.buttonAppearance line. It says that Reference to member tintColor cannot be resolved without a contextual type.

meaning-matters
  • 21,929
  • 10
  • 82
  • 142
Muhaimin
  • 93
  • 1
  • 6
  • `[.tintColor:navBarColor]` is clearly incorrect syntactically. Then `buttonAppearance` is of type `UIBarButtonItemAppearance`, which doesn't allow setting the tint color. Have a look at [this](https://stackoverflow.com/a/28734280/1971013). – meaning-matters Feb 11 '23 at 23:00

0 Answers0