Reputation: 2213
I'm having trouble changing the font and fontsize of a placeholder inside a UITextField.
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);
Upvotes: 1
Views: 961
Reputation: 2529
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)});
Upvotes: 1