Qazi Ammar
Qazi Ammar

Reputation: 1518

Change the color of a focused element (Picker) SwiftUI - WatchOS

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.

Upvotes: 8

Views: 1288

Answers (3)

KM42
KM42

Reputation: 1

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

Upvotes: 0

gmoraleda
gmoraleda

Reputation: 1953

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.

Upvotes: 2

Luka Šalipur
Luka Šalipur

Reputation: 49

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

Upvotes: -1

Related Questions