[iOS] workaround a weird iOS behavior. (#987)

This commit is contained in:
Stephane Delcroix 2017-06-21 03:00:58 +02:00 коммит произвёл Rui Marinho
Родитель 723cb80c6b
Коммит b7b0bf559a
2 изменённых файлов: 22 добавлений и 14 удалений

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

@ -88,25 +88,21 @@ namespace Xamarin.Forms
set { SetValue(FontSizeProperty, value); }
}
void IFontElement.OnFontFamilyChanged(string oldValue, string newValue)
{
}
void IFontElement.OnFontSizeChanged(double oldValue, double newValue)
{
}
double IFontElement.FontSizeDefaultValueCreator() =>
Device.GetNamedSize(NamedSize.Default, (Entry)this);
void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue)
{
}
void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue) =>
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
void IFontElement.OnFontChanged(Font oldValue, Font newValue)
{
}
void IFontElement.OnFontFamilyChanged(string oldValue, string newValue) =>
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
void IFontElement.OnFontSizeChanged(double oldValue, double newValue) =>
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
void IFontElement.OnFontChanged(Font oldValue, Font newValue) =>
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
public event EventHandler Completed;
public event EventHandler<TextChangedEventArgs> TextChanged;

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

@ -17,6 +17,18 @@ namespace Xamarin.Forms.Platform.iOS
Frame = new RectangleF(0, 20, 320, 40);
}
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
//with borderStyle set to RoundedRect, iOS always returns a height of 30
//https://stackoverflow.com/a/36569247/1063783
//we get the current value, and restor it, to allow custom renderers to change the border style
var borderStyle = Control.BorderStyle;
Control.BorderStyle = UITextBorderStyle.None;
var size = Control.GetSizeRequest(widthConstraint, double.PositiveInfinity);
Control.BorderStyle = borderStyle;
return size;
}
IElementController ElementController => Element as IElementController;
protected override void Dispose(bool disposing)