HideShowPassword is an easy to use xamarin ios extension of UITextField and/or the MaterialComponents TextField to toggle the password visibility in a text field. Just tap the eye icon on right view to toggle visibility.
View the sample application - * HideShowPasswordSample
- Add a UITextField to your Storyboard or Nib layout and select HideShowPasswordTextField as the Class
- Or just select the Hide Show Password Text Field from toolbox custom controls
- Optionally extend
IHideShowPassWordTextFieldDelegate
and implementIsValidPassword
to show a checkmark if password is valid and setpasswordDelegate
- Optionally extend
IUITextFieldDelegate
and overrideEditingEnded
to reset secure entry when not in focus and set text fieldDelegate
public class ViewController : UIViewController, IHideShowPassWordTextFieldDelegate, IUITextFieldDelegate
{
protected ViewController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
InitComponents();
}
void InitComponents()
{
// Set Delegates on normal UITextField password
password.passwordDelegate = this;
password.Delegate = this;
// Optionally set tint color on right view
password.RightView.TintColor = UIColor.Blue;
}
/* Optionally implement interface member for Native UITextField IsValidPassword,
* To show a checkmark in field if the entered password is correct
*/
public bool IsValidPassword(UITextField textField, string password)
{
return password.Length > 5;
}
[Export("textFieldDidEndEditing:")]
public void EditingEnded(UITextField textField)
{
/* After editing of text field was complete,
* you can call the TextFieldDidEndEditing to change it back to a secure text entry.
*
* You can set an Accessibility label for these text fields in the UI designer to determine from which textField the editing was ended
*/
switch (textField.AccessibilityLabel)
{
case "Password":
password.TextFieldDidEndEditing(textField);
break;
}
}
}
Xamarin HideShowPassword for iOS
Copyright (c) 2019 Xamarin HideShowPassword for iOS Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.