adjust UI

This commit is contained in:
2021-08-10 17:17:32 +08:00
parent f8850073cd
commit 6507f7cadf
100 changed files with 3138 additions and 963 deletions

View File

@ -0,0 +1,56 @@
using System.ComponentModel;
using Gallery.iOS.Renderers;
using Gallery.Resources.UI;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(RoundLabel), typeof(RoundLabelRenderer))]
namespace Gallery.iOS.Renderers
{
public class RoundLabelRenderer : LabelRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
var layer = Layer;
if (layer != null && e.NewElement is RoundLabel label)
{
var radius = label.CornerRadius;
if (radius > 0)
{
layer.CornerRadius = radius;
//layer.MasksToBounds = true;
}
else
{
layer.CornerRadius = 0;
}
if (layer.BackgroundColor != default)
{
layer.BackgroundColor = label.BackgroundColor.ToCGColor();
}
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == RoundLabel.CornerRadiusProperty.PropertyName)
{
var layer = Layer;
if (layer != null && Element is RoundLabel label)
{
var radius = label.CornerRadius;
if (radius > 0)
{
layer.CornerRadius = radius;
layer.BackgroundColor = label.BackgroundColor.ToCGColor();
//layer.MasksToBounds = true;
}
}
}
}
}
}