skip to Main Content

How can I change the focus color of a selected element in WatchOS7 with swiftUI. Here’s my example below with a Picker whose focus color is green (the default one) but I want to change it to blue to be consistant with my app layout.

enter image description here

I search over the internet and stackoverflow but did not find andy solution to this. Is it possible to do it in SwiftUI.

3

Answers


  1. Maybe you should try using .accentColor modifier to the picker.

    Login or Signup to reply.
  2. That’s the focus color and you cannot change it. At least no with standard view modifiers like .accentColor, .tint, etc.

    You can try to hide it by overlying another view (like in this response), for example, or try to reach to UIKit using instrospection.

    Probably it’s best to be at peace with the fact that it’s system behavior.

    Login or Signup to reply.
  3. If you don’t mind building your own picker-type view, you can use .digitalCrownRotation() instead of the picker as discussed here in regards to hiding the border: https://stackoverflow.com/a/75909943/21505031

    Example code here: https://www.hackingwithswift.com/quick-start/swiftui/how-to-read-the-digital-crown-on-watchos-using-digitalcrownrotation

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search