public JVFloatLabeledEntryElement(string placeholder, string value = null, string caption = null, bool isPassword = false) : base(caption, placeholder, value, isPassword) { _textField = new JVFloatLabeledTextField(RectangleF.Empty) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleLeftMargin, Placeholder = placeholder, Text = value, SecureTextEntry = isPassword }; }
public override void ViewDidLoad() { base.ViewDidLoad(); float topOffset = UIApplication.SharedApplication.StatusBarFrame.Size.Height + NavigationController.NavigationBar.Frame.Size.Height; UIColor floatingLabelColor = UIColor.Gray, floatingLabelActiveColor = UIColor.Blue; var usernameField = new JVFloatLabeledTextField(new RectangleF(JVFieldHMargin, topOffset, View.Frame.Size.Width - 2 * JVFieldHMargin, JVFieldHeight)) { Placeholder = "Username", Font = UIFont.SystemFontOfSize(JVFieldFontSize), ClearButtonMode = UITextFieldViewMode.WhileEditing, FloatingLabelFont = UIFont.BoldSystemFontOfSize(JVFieldFloatingLabelFontSize), FloatingLabelTextColor = floatingLabelColor, FloatingLabelActiveTextColor = floatingLabelActiveColor }; View.AddSubview(usernameField); var div1 = new UIView(new RectangleF(JVFieldHMargin, usernameField.Frame.Y + usernameField.Frame.Size.Height, View.Frame.Size.Width - 2 * JVFieldHMargin, 1)) { BackgroundColor = UIColor.LightGray.ColorWithAlpha(0.3f) }; View.AddSubview(div1); //var passwordField = new JVFloatLabeledEntryElement ("Password", isPassword: true); var passwordField = new JVFloatLabeledTextField(new RectangleF(JVFieldHMargin, div1.Frame.Y + div1.Frame.Size.Height, View.Frame.Size.Width - 2 * JVFieldHMargin, JVFieldHeight)) { Placeholder = "Password", Font = UIFont.SystemFontOfSize(JVFieldFontSize), FloatingLabelFont = UIFont.BoldSystemFontOfSize(JVFieldFloatingLabelFontSize), FloatingLabelTextColor = floatingLabelColor, FloatingLabelActiveTextColor = floatingLabelActiveColor, SecureTextEntry = true }; View.AddSubview(passwordField); var div2 = new UIView(new RectangleF(JVFieldHMargin, passwordField.Frame.Y + passwordField.Frame.Size.Height, View.Frame.Size.Width - 2 * JVFieldHMargin, 1)) { BackgroundColor = UIColor.LightGray.ColorWithAlpha(0.3f) }; View.AddSubview(div2); var passwordConfirmField = new JVFloatLabeledTextField(new RectangleF(JVFieldHMargin, div2.Frame.Y + div2.Frame.Size.Height, View.Frame.Size.Width - 2 * JVFieldHMargin, JVFieldHeight)) { Placeholder = "Confirm Password", Font = UIFont.SystemFontOfSize(JVFieldFontSize), FloatingLabelFont = UIFont.BoldSystemFontOfSize(JVFieldFloatingLabelFontSize), FloatingLabelTextColor = floatingLabelColor, FloatingLabelActiveTextColor = floatingLabelActiveColor, SecureTextEntry = true }; View.AddSubview(passwordConfirmField); usernameField.BecomeFirstResponder(); //Hiding Keypad var tap = new UITapGestureRecognizer(); tap.AddTarget(() => { View.EndEditing(true); }); View.AddGestureRecognizer(tap); }