Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This repository was archived by the owner on May 28, 2025. It is now read-only.

Apparent vertical alignment of UITextField #589

@ehren

Description

@ehren

Have a bit of a styling issue related to the underlying Xaml TextBox of UITextField. I'm not sure if this is inherent with TextBox but the text is always drawn with an apparent top vertical alignment e.g. screenshots from the WOCCatalog app:

screen shot 2016-06-28 at 10 16 03 am
screen shot 2016-06-28 at 10 16 18 am

Sometimes this works visually (and there are a few things that can be done to mitigate this issue and make the apparent vertical alignment fit with an app's design). But it would be nice if there was a way to adjust this.

The obvious fix - to try setting VerticalAlignmentCenter when the Xaml TextBox is loaded seems to have no effect (also didn't witness a change when using WXVerticalAlignmentBottom):

diff --git a/Frameworks/UIKit/UITextField.mm b/Frameworks/UIKit/UITextField.mm
index 4cf357e..afd395f 100644
--- a/Frameworks/UIKit/UITextField.mm
+++ b/Frameworks/UIKit/UITextField.mm
@@ -1061,6 +1061,8 @@ NSString* const UITextFieldTextDidEndEditingNotification = @"UITextFieldTextDidE
             strongSelf->_textBox.text = strongSelf.text;
             strongSelf->_textBox.placeholderText = strongSelf.placeholder;
             strongSelf->_textBox.isSpellCheckEnabled = (strongSelf.spellCheckingType == UITextSpellCheckingTypeYes);
+            strongSelf->_textBox.verticalContentAlignment = WXVerticalAlignmentCenter;
+            strongSelf->_textBox.verticalAlignment = WXVerticalAlignmentCenter;
         }
     }];

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions