Home > Net >  How to change the indicator color of Textfield in SwiftUI?
How to change the indicator color of Textfield in SwiftUI?

Time:10-28

I'm trying to change the indicator color of SwiftUI TextField. Like the orange bar in the image below, to change it from orange to blue.

So far, the only place that seems to work is to change the accent color in Xcode assets directly. But I wanna to change it in code. Does anyone knows how to do that?

Thank you!

TextField("What's in your mind?", text: $userInput)

enter image description here

CodePudding user response:

We ca explicitly set the accent color of the view.

TextField("What's in your mind?", text: $userInput)
 .accentColor(.blue) //<= here

CodePudding user response:

Solved. guys~ It's a bug of iOS 16 / iPadOS 16.

Updating to iOS 16.1 will fix that bug. And .tint will correctly applied.

  • Related