/// <summary> /// Sets the color of the placeholder text. /// </summary> /// <param name="view">The view.</param> private void SetPlaceholderTextColor(xEntry view) { if (view.PlaceholderTextColor != Color.Default) { Control.SetHintTextColor(view.PlaceholderTextColor.ToAndroid()); } }
/// <summary> /// Sets the font. /// </summary> /// <param name="view">The view.</param> private void SetFont(xEntry view) { if (view.Font != Font.Default) { Control.TextSize = view.Font.ToScaledPixel(); } }
/// <summary> /// Sets the maxLength. /// </summary> /// <param name="view">The view.</param> private void SetMaxLength(xEntry view) { Control.ShouldChangeCharacters = (textField, range, replacementString) => { var newLength = textField.Text.Length + replacementString.Length - range.Length; return(newLength <= view.MaxLength); }; }
private void SetFont(xEntry view) { UIFont uiFont; if (view.Font != Font.Default && (uiFont = view.Font.ToUIFont()) != null) { Control.Font = uiFont; } else if (view.Font == Font.Default) { Control.Font = UIFont.SystemFontOfSize(17f); } }
///// <summary> ///// Sets the border. ///// </summary> ///// <param name="view">The view.</param> private void SetBorder(xEntry view) { if (view.HasBorder == false) { var shape = new ShapeDrawable(new RectShape()); shape.Paint.Alpha = 0; shape.Paint.SetStyle(Paint.Style.Stroke); Control.SetBackgroundDrawable(shape); } else { Control.SetBackground(originalBackground); } }
/// <summary> /// Sets the color of the placeholder text. /// </summary> /// <param name="view">The view.</param> void SetPlaceholderTextColor(xEntry view) { /* * UIColor *color = [UIColor lightTextColor]; * YOURTEXTFIELD.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"PlaceHolder Text" attributes:@{NSForegroundColorAttributeName: color}]; */ if (string.IsNullOrEmpty(view.Placeholder) == false && view.PlaceholderTextColor != Color.Default) { NSAttributedString placeholderString = new NSAttributedString(view.Placeholder, new UIStringAttributes() { ForegroundColor = view.PlaceholderTextColor.ToUIColor() }); Control.AttributedPlaceholder = placeholderString; } }
private void SetTextAlignment(xEntry view) { switch (view.XAlign) { case TextAlignment.Center: Control.TextAlignment = UITextAlignment.Center; break; case TextAlignment.End: Control.TextAlignment = UITextAlignment.Right; break; case TextAlignment.Start: Control.TextAlignment = UITextAlignment.Left; break; } }
/// <summary> /// Sets the text alignment. /// </summary> /// <param name="view">The view.</param> private void SetTextAlignment(xEntry view) { switch (view.XAlign) { case Xamarin.Forms.TextAlignment.Center: Control.Gravity = GravityFlags.CenterHorizontal; break; case Xamarin.Forms.TextAlignment.End: Control.Gravity = GravityFlags.End; break; case Xamarin.Forms.TextAlignment.Start: Control.Gravity = GravityFlags.Start; break; } }
/// <summary> /// Sets the border. /// </summary> /// <param name="view">The view.</param> private void SetBorder(xEntry view) { Control.BorderStyle = view.HasBorder ? UITextBorderStyle.RoundedRect : UITextBorderStyle.None; }
/// <summary> /// Sets the MaxLength characteres. /// </summary> /// <param name="view">The view.</param> private void SetMaxLength(xEntry view) { Control.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(view.MaxLength) }); }