bcstrawn
bcstrawn

Reputation: 187

Xamarin: Set UITextField Height

How do I change the height of a text field in Xamarin iOS?

In native iOS, you can set the height on the UITextField outlet manually, like in this answer, but in Xamarin, it doesn't allow you to change that property. Is this possible in Xamarin using an actual UITextField? If not, what's the nicest hack to get something similar?

Upvotes: 12

Views: 4013

Answers (3)

Noble Jacob
Noble Jacob

Reputation: 1

UsernameText.Frame = new CoreGraphics.CGRect(UsernameText.Frame.X, UsernameText.Frame.Y,UsernameText.Frame.Width, UsernameText.Frame.Height + 5);

Upvotes: 0

SKall
SKall

Reputation: 5234

RectangleF in C# is a struct so you will need to make a copy of it, change the value and set it back to the control.

        var f = textField.Frame;

        f.Height = 100f;

        textField.Frame = f;

Upvotes: 11

Ender2050
Ender2050

Reputation: 6992

Have you tried setting the frame like this?

textField.Frame = new RectangleF (x, y, width, height);

Upvotes: 5

Related Questions