[iOS] Check new element before creating placeholder label (#5432)

* Check new element before creating placeholder label

* additional checks

* create placeholder once
This commit is contained in:
E.Z. Hart 2019-03-05 11:06:27 -07:00 коммит произвёл Samantha Houts
Родитель 21c7567e02
Коммит a372395fb2
1 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -31,16 +31,24 @@ namespace Xamarin.Forms.Platform.iOS
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{
bool initializing = false;
if (e.NewElement != null && _placeholderLabel == null)
{
initializing = true;
// create label so it can get updated during the initial setup loop
_placeholderLabel = new UILabel
{
BackgroundColor = UIColor.Clear
};
}
base.OnElementChanged(e);
if (e.NewElement != null && initializing)
{
CreatePlaceholderLabel();
}
}
protected internal override void UpdateFont()
{
@ -63,6 +71,9 @@ namespace Xamarin.Forms.Platform.iOS
void CreatePlaceholderLabel()
{
if (Control == null)
return;
Control.AddSubview(_placeholderLabel);
var edgeInsets = TextView.TextContainerInset;