[英]NSAttributedString not working on UITextField ios xamarin
I'm having trouble changing the font and fontsize of a placeholder inside a UITextField. 我在更改UITextField内部占位符的字体和fontsize时遇到麻烦。
this.emailTextField = new UITextField ();
//Not working
this.emailTextField.AttributedPlaceholder = new NSAttributedString ("Email address", UIFont.FromName("Didot-Italic", 6.0f));
this.emailTextField.KeyboardType = UIKeyboardType.EmailAddress;
this.emailTextField.ReturnKeyType = UIReturnKeyType.Next;
this.emailTextField.AdjustsFontSizeToFitWidth = true;
this.emailTextField.ClearButtonMode = UITextFieldViewMode.Always;
this.emailTextField.BackgroundColor = UIColor.White;
this.emailTextField.BorderStyle = UITextBorderStyle.None;
var bottomLayer = new CALayer ();
bottomLayer.BorderColor = UIColor.Black.CGColor;
bottomLayer.BorderWidth = 1;
bottomLayer.Frame = new RectangleF (0, 29, 200, 1);
this.emailTextField.Layer.AddSublayer (bottomLayer);
this.emailTextField.Frame = new RectangleF (60, this.fbButton.Frame.Bottom + 20, 200, 30);
You could try to use it like below. 您可以尝试如下使用它。 It worked me so far. 到目前为止,它对我有效。
this.emailTextField.AttributedPlaceholder = new NSAttributedString ("Email address", new UIStringAttributes{Font = UIFont.FromName("Didot-Italic", 6.0f)});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.