public void CreatePlaceholder() { var element = Element as ExtendedEditorControl; _placeholderLabel = new UILabel { Text = element?.Placeholder, TextColor = element.PlaceholderColor.ToUIColor(), BackgroundColor = UIColor.Clear }; var edgeInsets = Control.TextContainerInset; var lineFragmentPadding = Control.TextContainer.LineFragmentPadding; Control.AddSubview(_placeholderLabel); var vConstraints = NSLayoutConstraint.FromVisualFormat( "V:|-" + edgeInsets.Top + "-[PlaceholderLabel]-" + edgeInsets.Bottom + "-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys( new NSObject[] { _placeholderLabel }, new NSObject[] { new NSString("PlaceholderLabel") }) ); var hConstraints = NSLayoutConstraint.FromVisualFormat( "H:|-" + lineFragmentPadding + "-[PlaceholderLabel]-" + lineFragmentPadding + "-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys( new NSObject[] { _placeholderLabel }, new NSObject[] { new NSString("PlaceholderLabel") }) ); _placeholderLabel.TranslatesAutoresizingMaskIntoConstraints = false; Control.AddConstraints(hConstraints); Control.AddConstraints(vConstraints); }
void CreatePlaceholderLabel() { if (Control == null) { return; } Control.AddSubview(_placeholderLabel); var edgeInsets = TextView.TextContainerInset; var lineFragmentPadding = TextView.TextContainer.LineFragmentPadding; var vConstraints = NSLayoutConstraint.FromVisualFormat( "V:|-" + edgeInsets.Top + "-[_placeholderLabel]-" + edgeInsets.Bottom + "-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys( new NSObject[] { _placeholderLabel }, new NSObject[] { new NSString("_placeholderLabel") }) ); var hConstraints = NSLayoutConstraint.FromVisualFormat( "H:|-" + lineFragmentPadding + "-[_placeholderLabel]-" + lineFragmentPadding + "-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys( new NSObject[] { _placeholderLabel }, new NSObject[] { new NSString("_placeholderLabel") }) ); _placeholderLabel.TranslatesAutoresizingMaskIntoConstraints = false; _placeholderLabel.AttributedText = _placeholderLabel.AttributedText.AddCharacterSpacing(Element.Placeholder, Element.CharacterSpacing); Control.AddConstraints(hConstraints); Control.AddConstraints(vConstraints); }
void CreatePlaceholderLabel() { try { _placeholderLabel = new UILabel { BackgroundColor = UIColor.Clear, Font = UIFont.FromName(ElementEx.FontFamily, (nfloat)ElementEx.FontSize) }; UpdatePlaceholder(); UpdatePlaceholderColor(); _placeholderLabel.SizeToFit(); Control.AddSubview(_placeholderLabel); Control.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); Control.AddConstraints ( _placeholderLabel.AtLeftOf(Control, 7), _placeholderLabel.WithSameCenterY(Control) ); Control.LayoutIfNeeded(); _placeholderLabel.Hidden = Control.HasText; } catch (Exception ex) { var message = ex.Message; } }
void createLabel() { _placeholderLabel = new UILabel { BackgroundColor = UIColor.Clear, }; Control.AddSubview(_placeholderLabel); var edgeInsets = Control.TextContainerInset; var lineFragmentPadding = Control.TextContainer.LineFragmentPadding; var vConstraints = NSLayoutConstraint.FromVisualFormat( "V:|-" + edgeInsets.Top + "-[_placeholderLabel]-" + edgeInsets.Bottom + "-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys( new NSObject[] { _placeholderLabel }, new NSObject[] { new NSString("_placeholderLabel") })); var hConstraints = NSLayoutConstraint.FromVisualFormat( "H:|-" + lineFragmentPadding + "-[_placeholderLabel]-" + lineFragmentPadding + "-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys( new NSObject[] { _placeholderLabel }, new NSObject[] { new NSString("_placeholderLabel") }) ); _placeholderLabel.TranslatesAutoresizingMaskIntoConstraints = false; Control.AddConstraints(hConstraints); Control.AddConstraints(vConstraints); }
protected override void OnElementChanged(ElementChangedEventArgs <Editor> e) { base.OnElementChanged(e); if (e.NewElement != null) { Control.ScrollEnabled = false; Control.TintColor = UIColor.FromRGB(199, 175, 149); // Control.TextColor = editor.TextColor.ToUIColor(); SetCharacterSpacing(e.NewElement as ExtendedEditor); SetColor(Element as ExtendedEditor); SetDefaultSettingColor(Element as ExtendedEditor); } if (PlaceholderLabel != null) { return; } var element = Element as ExtendedEditor; PlaceholderLabel = new PaddedLabel(element.PaddingTop, element.PaddingLeft, element.PaddingRight, element.PaddingBottom); PlaceholderLabel.Text = element?.Placeholder; PlaceholderLabel.TextColor = element?.PlaceholderColor.ToUIColor(); PlaceholderLabel.BackgroundColor = UIColor.Clear; var edgeInsets = Control.TextContainerInset; var lineFragmentPadding = Control.TextContainer.LineFragmentPadding; Control.AddSubview(PlaceholderLabel); var vConstraints = NSLayoutConstraint.FromVisualFormat( "V:|-" + edgeInsets.Top + "-[PlaceholderLabel]-" + edgeInsets.Bottom + "-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys( new NSObject[] { PlaceholderLabel }, new NSObject[] { new NSString("PlaceholderLabel") }) ); var hConstraints = NSLayoutConstraint.FromVisualFormat( "H:|-" + lineFragmentPadding + "-[PlaceholderLabel]-" + lineFragmentPadding + "-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys( new NSObject[] { PlaceholderLabel }, new NSObject[] { new NSString("PlaceholderLabel") }) ); PlaceholderLabel.TranslatesAutoresizingMaskIntoConstraints = false; Control.AddConstraints(hConstraints); Control.AddConstraints(vConstraints); }