added custom font renderers for ios dynamic text
This commit is contained in:
parent
818b1c426f
commit
734d2632dc
|
@ -0,0 +1,40 @@
|
||||||
|
using System;
|
||||||
|
using Bit.iOS.Controls;
|
||||||
|
using UIKit;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Platform.iOS;
|
||||||
|
|
||||||
|
[assembly: ExportRenderer(typeof(Label), typeof(CustomLabelRenderer))]
|
||||||
|
namespace Bit.iOS.Controls
|
||||||
|
{
|
||||||
|
public class CustomLabelRenderer : LabelRenderer
|
||||||
|
{
|
||||||
|
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
|
||||||
|
{
|
||||||
|
base.OnElementChanged(e);
|
||||||
|
|
||||||
|
var view = e.NewElement as Label;
|
||||||
|
if(Control != null && view != null)
|
||||||
|
{
|
||||||
|
var descriptor = UIFontDescriptor.PreferredBody;
|
||||||
|
var pointSize = descriptor.PointSize;
|
||||||
|
|
||||||
|
var size = view.FontSize;
|
||||||
|
if(size == Device.GetNamedSize(NamedSize.Large, typeof(Label)))
|
||||||
|
{
|
||||||
|
pointSize *= 1.7f;
|
||||||
|
}
|
||||||
|
else if(size == Device.GetNamedSize(NamedSize.Small, typeof(Label)))
|
||||||
|
{
|
||||||
|
pointSize *= .8f;
|
||||||
|
}
|
||||||
|
else if(size == Device.GetNamedSize(NamedSize.Micro, typeof(Label)))
|
||||||
|
{
|
||||||
|
pointSize *= .6f;
|
||||||
|
}
|
||||||
|
|
||||||
|
UIFont.FromDescriptor(descriptor, pointSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,8 @@ namespace Bit.iOS.Controls
|
||||||
var view = e.NewElement as ExtendedEntry;
|
var view = e.NewElement as ExtendedEntry;
|
||||||
if(view != null)
|
if(view != null)
|
||||||
{
|
{
|
||||||
|
UIFont.FromDescriptor(UIFontDescriptor.PreferredBody, 1.0f);
|
||||||
|
|
||||||
SetBorder(view);
|
SetBorder(view);
|
||||||
SetMaxLength(view);
|
SetMaxLength(view);
|
||||||
UpdateKeyboard();
|
UpdateKeyboard();
|
||||||
|
|
|
@ -101,6 +101,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Controls\ContentPageRenderer.cs" />
|
<Compile Include="Controls\ContentPageRenderer.cs" />
|
||||||
|
<Compile Include="Controls\CustomLabelRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedSwitchCellRenderer.cs" />
|
<Compile Include="Controls\ExtendedSwitchCellRenderer.cs" />
|
||||||
<Compile Include="Controls\ListViewRenderer.cs" />
|
<Compile Include="Controls\ListViewRenderer.cs" />
|
||||||
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
|
<Compile Include="Controls\ExtendedViewCellRenderer.cs" />
|
||||||
|
|
Loading…
Reference in New Issue