4

Is it possible to set padding inside a UITextField, if so how?

marcus
  • 9,616
  • 9
  • 58
  • 108
  • 1
    See [Here](http://stackoverflow.com/questions/3727068/set-padding-for-uitextfield-with-uitextborderstylenone) – Luke Sep 28 '10 at 13:49

1 Answers1

5

I was also wondering, here you are:

UIView paddingView = new UIView(new CGRect(0, 0, 5, 20));
YourTextField.LeftView = paddingView;
YourTextField.LeftViewMode = UITextFieldViewMode.Always;

You can modify padding size of course by changing values above.

Hope this will help.

Daniel Krzyczkowski
  • 2,732
  • 2
  • 20
  • 30
  • UITextField does not contain definition for LeftView. – Woj Nov 19 '18 at 13:01
  • Worked great for me in a Custom renderor. I put it on the right as follows: UIView paddingView = new UIView(new CGRect(0, 0, 40, 20)); //paddingView.BackgroundColor = UIColor.Red; //for testing Control.RightView = paddingView; Control.RightViewMode = UITextFieldViewMode.Always; – Sabel Sep 14 '21 at 11:35