Lucas Goldner
Lucas Goldner

Reputation: 720

How the remove the yellow bar for "strong password" for SecureFields in SwiftUI?

I am new to SwiftUI and am trying out the SecureFields now. I am using two SecureFields in one VStack and for some reason when I use the iOS keyboard they show this yellow bar with a strong password. Is there any way of removing this "strong password" yellow bar?

Showing the issue

Code:

 VStack(spacing: 0) {
                if showFirst {
                    TextField(placeholderTextFirst, text: $inputFirst)
                        .foregroundColor(colorScheme == .light
                            ? invalidFirst ? .red
                            : color : invalidFirst ? .red : .white)
                        .padding()
                        .placeholder(when: inputFirst.isEmpty) {
                            Text(placeholderTextFirst)
                                .foregroundColor(placeholderColor)
                                .padding()
                        }
                } else {
                    SecureField(placeholderTextFirst, text: $inputFirst)
                        .foregroundColor(colorScheme == .light
                            ? invalidFirst ? .red
                            : color : invalidFirst ? .red : .white)
                        .padding()
                        .placeholder(when: inputFirst.isEmpty) {
                            Text(placeholderTextFirst)
                                .foregroundColor(placeholderColor)
                                .padding()
                        }
                }
                if showSecond {
                    TextField(placeholderTextSecond, text: $inputSecond)
                        .foregroundColor(colorScheme == .light
                            ? invalidSecond ? .red
                            : color : invalidSecond ? .red : .white)
                        .padding().ignoresSafeArea(.keyboard, edges: .bottom)
                        .placeholder(when: inputSecond.isEmpty) {
                            Text(placeholderTextSecond).foregroundColor(placeholderColor)
                                .padding()
                        }
                } else {
                    SecureField(placeholderTextSecond, text: $inputSecond)
                        .foregroundColor(colorScheme == .light
                            ? invalidSecond ? .red
                            : color : invalidSecond ? .red : .white)
                        .padding().ignoresSafeArea(.keyboard, edges: .bottom)
                        .placeholder(when: inputSecond.isEmpty) {
                            Text(placeholderTextSecond).foregroundColor(placeholderColor)
                                .padding()
                        }
                }
            }
        }
    }

Upvotes: 2

Views: 824

Answers (1)

Lucas Goldner
Lucas Goldner

Reputation: 720

Found the fix myself just add:

.textContentType(.oneTimeCode)

Upvotes: 0

Related Questions