public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. fingerPrintView.Hidden = true; userNameTF.Hidden = true; passwordTF.Hidden = true; loadTheme(); int hexColor = unchecked ((int)0xFFDB642C); activeColor = UIColor.Clear.FromHex(hexColor); // float topOffset = (float)(UIApplication.SharedApplication.StatusBarFrame.Size.Height + NavigationController.NavigationBar.Frame.Size.Height); UIColor floatingLabelColor = UIColor.Gray, floatingLabelActiveColor = activeColor; var userNameField = new FloatLabeledTextField(new CGRect(0, 8, 335, 50)) { Placeholder = "User Name", Font = UIFont.SystemFontOfSize(FieldFontSize), ClearButtonMode = UITextFieldViewMode.WhileEditing, FloatingLabelFont = UIFont.BoldSystemFontOfSize(FieldFloatingLabelFontSize), FloatingLabelTextColor = floatingLabelColor, FloatingLabelActiveTextColor = floatingLabelActiveColor }; InputContainerView.AddSubview(userNameField); var passwordField = new FloatLabeledTextField(new CGRect(0, 66, 335, 50)) { Placeholder = "Password", Font = UIFont.SystemFontOfSize(FieldFontSize), ClearButtonMode = UITextFieldViewMode.WhileEditing, FloatingLabelFont = UIFont.BoldSystemFontOfSize(FieldFloatingLabelFontSize), FloatingLabelTextColor = floatingLabelColor, FloatingLabelActiveTextColor = floatingLabelActiveColor }; InputContainerView.AddSubview(passwordField); userNameField.ClearButtonMode = UITextFieldViewMode.Never; userNameField.AutocorrectionType = UITextAutocorrectionType.No; userNameField.AutocapitalizationType = UITextAutocapitalizationType.None; //userNameField.ReturnKeyType = UIReturnKeyType.Continue; //userNameField.AddConstraint(NSLayoutConstraint ); userNameField.LeftViewMode = UITextFieldViewMode.Always; userNameField.LeftView = new UIImageView(UIImage.FromBundle("cloud"));; passwordField.ClearButtonMode = UITextFieldViewMode.Never; passwordField.SecureTextEntry = true; passwordField.AutocorrectionType = UITextAutocorrectionType.No; passwordField.AutocapitalizationType = UITextAutocapitalizationType.None; var border = new CALayer(); nfloat width = 2; border.BorderColor = floatingLabelColor.CGColor; border.Frame = new CoreGraphics.CGRect(0, userNameField.Frame.Size.Height - width, userNameField.Frame.Size.Width, userNameField.Frame.Size.Height); border.BorderWidth = width; userNameField.Layer.AddSublayer(border); userNameField.Layer.MasksToBounds = true; userNameField.EditingDidBegin += (sender, e) => { Console.WriteLine("NEWuserNameField touched"); border.BorderColor = activeColor.CGColor; }; userNameField.EditingDidEnd += (sender, e) => { Console.WriteLine("NEWuserNameField NOT touched"); border.BorderColor = floatingLabelColor.CGColor; }; var borderP = new CALayer(); // nfloat width = 2; borderP.BorderColor = floatingLabelColor.CGColor; borderP.Frame = new CoreGraphics.CGRect(0, passwordField.Frame.Size.Height - width, passwordField.Frame.Size.Width, passwordField.Frame.Size.Height); borderP.BorderWidth = width; passwordField.Layer.AddSublayer(borderP); passwordField.Layer.MasksToBounds = true; passwordField.EditingDidBegin += (sender, e) => { Console.WriteLine("passwordField touched"); borderP.BorderColor = activeColor.CGColor; }; passwordField.EditingDidEnd += (sender, e) => { Console.WriteLine("passwordField NOTouched"); borderP.BorderColor = floatingLabelColor.CGColor; }; }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Floating Label Demo"; View.BackgroundColor = UIColor.White; float topOffset = (float)(UIApplication.SharedApplication.StatusBarFrame.Size.Height + NavigationController.NavigationBar.Frame.Size.Height); UIColor floatingLabelColor = UIColor.Gray, floatingLabelActiveColor = UIColor.Blue; var titleField = new FloatLabeledTextField(new CGRect(FieldHMargin, topOffset, View.Frame.Size.Width - 2 * FieldHMargin, FieldHeight)) { Placeholder = "Title", Font = UIFont.SystemFontOfSize(FieldFontSize), ClearButtonMode = UITextFieldViewMode.WhileEditing, FloatingLabelFont = UIFont.BoldSystemFontOfSize(FieldFloatingLabelFontSize), FloatingLabelTextColor = floatingLabelColor, FloatingLabelActiveTextColor = floatingLabelActiveColor }; View.AddSubview(titleField); var div1 = new UIView(new CGRect(FieldHMargin, titleField.Frame.Y + titleField.Frame.Size.Height, View.Frame.Size.Width - 2 * FieldHMargin, 1)) { BackgroundColor = UIColor.LightGray.ColorWithAlpha(0.3f) }; View.AddSubview(div1); var priceField = new FloatLabeledTextField(new CGRect(FieldHMargin, div1.Frame.Y + div1.Frame.Size.Height, 80, FieldHeight)) { Placeholder = "Price", Font = UIFont.SystemFontOfSize(FieldFontSize), FloatingLabelFont = UIFont.BoldSystemFontOfSize(FieldFloatingLabelFontSize), FloatingLabelTextColor = floatingLabelColor, FloatingLabelActiveTextColor = floatingLabelActiveColor, Text = "3.14" }; View.AddSubview(priceField); var div2 = new UIView(new CGRect(FieldHMargin + priceField.Frame.Size.Width, titleField.Frame.Y + titleField.Frame.Size.Height, 1, FieldHeight)) { BackgroundColor = UIColor.LightGray.ColorWithAlpha(0.3f) }; View.AddSubview(div2); var locationField = new FloatLabeledTextField(new CGRect(FieldHMargin + FieldHMargin + priceField.Frame.Size.Width + 1.0f, div1.Frame.Y + div1.Frame.Size.Height, View.Frame.Size.Width - 3 * FieldHMargin - priceField.Frame.Size.Width - 1.0f, FieldHeight)) { Placeholder = "Specific Location (optional)", Font = UIFont.SystemFontOfSize(FieldFontSize), FloatingLabelFont = UIFont.BoldSystemFontOfSize(FieldFloatingLabelFontSize), FloatingLabelTextColor = floatingLabelColor, FloatingLabelActiveTextColor = floatingLabelActiveColor }; View.AddSubview(locationField); var div3 = new UIView(new CGRect(FieldHMargin, priceField.Frame.Y + priceField.Frame.Size.Height, View.Frame.Size.Width - 2 * FieldHMargin, 1)) { BackgroundColor = UIColor.LightGray.ColorWithAlpha(0.3f) }; View.AddSubview(div3); var descriptionField = new FloatLabeledTextField(new CGRect(FieldHMargin, div3.Frame.Y + div3.Frame.Size.Height, View.Frame.Size.Width - 2 * FieldHMargin, FieldHeight)) { Placeholder = "Description", Font = UIFont.SystemFontOfSize(FieldFontSize), FloatingLabelFont = UIFont.BoldSystemFontOfSize(FieldFloatingLabelFontSize), FloatingLabelTextColor = floatingLabelColor, FloatingLabelActiveTextColor = floatingLabelActiveColor }; View.AddSubview(descriptionField); titleField.BecomeFirstResponder(); NavigationItem.RightBarButtonItem = new UIBarButtonItem("Dialog Demo", UIBarButtonItemStyle.Plain, (s, a) => NavigationController.PushViewController(new DialogDemoViewController(), true)); }
protected override void OnElementChanged(ElementChangedEventArgs <NyEntry> e) { base.OnElementChanged(e); if (e.NewElement == null) { return; } var ent = e.NewElement; if (Control == null) { UITextField textField = null; switch (ent.EntryStyle) { case NyEntryStyle.FloatLabeled: textField = new FloatLabeledTextField( new System.Drawing.RectangleF(JVFieldHMargin, 0, (float)ent.WidthRequest, (float)ent.HeightRequest) ) { FloatingLabelFont = UIFont.BoldSystemFontOfSize(JVFieldFloatingLabelFontSize), BorderStyle = UITextBorderStyle.None, }; textField.BorderStyle = UITextBorderStyle.None; break; case NyEntryStyle.Rounded: textField = new UITextFieldWithPadding() { Padding = ent.RoundedPadding }; textField.BorderStyle = UITextBorderStyle.None; textField.Layer.BorderColor = ent.RoundedBorderColor.ToCGColor(); textField.Layer.CornerRadius = ent.RoundedBorderRadius / 2; textField.Layer.BackgroundColor = ent.RoundedBackgroundColor.ToCGColor(); break; default: textField = new UITextField(); textField.BorderStyle = UITextBorderStyle.RoundedRect; break; } SetNativeControl(textField); _defaultTextColor = textField.TextColor; //textField.BorderStyle = UITextBorderStyle.RoundedRect; textField.ClipsToBounds = true; textField.EditingChanged += OnEditingChanged; textField.ShouldReturn = OnShouldReturn; textField.EditingDidBegin += OnEditingBegan; textField.EditingDidEnd += OnEditingEnded; } UpdatePlaceholder(); UpdatePassword(); UpdateText(); UpdateColor(); UpdateFont(); UpdateKeyboard(); UpdateAlignment(); UpdateAdjustsFontSizeToFitWidth(); UpdateNumericHandle(); }