Bug 291 - Creating a UITextField from code does not properly align editing rect
Summary: Creating a UITextField from code does not properly align editing rect
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-08-13 10:05 UTC by Jason Trahan
Modified: 2011-08-13 10:18 UTC (History)
1 user (show)

Tags: UITextField
Is this bug a regression?: ---
Last known good build:

Screenshot of issue (5.53 KB, image/jpeg)
2011-08-13 10:05 UTC, Jason Trahan

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jason Trahan 2011-08-13 10:05:10 UTC
Created attachment 123 [details]
Screenshot of issue

When creating a UITextField with a frame from code behind it does not properly align the text or the placeholder.  I'm not sure if this is due to the bug in #265 but I figured I would report it. Note that it doesn't matter if you set a placeholder or text value either way will cause the misalignment. Also note that this behavior is in the Simulator. I'm not sure if it acts the same on the device yet.

Steps to reproduce.
1. Create a xib and add a UITextField to it and just set a placeholder. 
   Leave all defaults except the width which I set to 200 for both contols.
2. In code do the following.
   // height of 31 below to match xib default.
   var textField = new UITextField(new RectangleF(0, YValue, 200, 31);
   textField.Font = UIFont.FromName("Helvetica", 12); // to match xib
   textField.Placeholder = "Code Generated";

Attached is a screenshot of the results.
Comment 1 Jason Trahan 2011-08-13 10:16:04 UTC
I forgot to mention in step 2 to set the BorderStyle to RoundedRect to match xib.
Comment 2 Jason Trahan 2011-08-13 10:18:32 UTC
Nevermind. It appears the VerticalAlignment when creating UITextField from code behind defaults to top instead of center.