Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SecureTextFiledForSwiftUI

This is a sample application of SwiftUI that
switches the input-form of the secure password to the form
that can confirm the entered character string by tapping the eye button.

Point of this sample

The point is to separate SecureField or TextField according to the bound Bool value (isSecured).
isSecured can be switched by tapping the eye button.
We can use SF Symbols for the eye and slash-eye icon images.

structPasswordView:View{@Stateprivatevarpassword:String=""@StateprivatevarisSecured:Bool=truevarbody:someView{HStack{ifself.isSecured {SecureField("Password", text: $password).textFieldStyle(RoundedBorderTextFieldStyle()).padding(.leading,20.0)}else{TextField("Password", text: $password).textFieldStyle(RoundedBorderTextFieldStyle()).padding(.leading,20.0)}Button(action:{self.isSecured.toggle()}){self.isSecured ?Image(systemName:"eye.slash.fill"):Image(systemName:"eye.fill")}.foregroundColor(.gray).padding(.trailing,20.0)}}}

GIF

SecureTextField

About

This is a sample application of SwiftUI that switches the input-form of the secure password to the form that can confirm the entered character string by tapping the eye button.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages