【发布时间】:2019-04-24 20:07:01
【问题描述】:
我在 Xamarin Form 项目中添加了 RoutingEffect,在我的 Xamarin.iOS 项目中添加了 PlatformEffect。它将为 Stacklayout 添加效果。本演示中的 Stacklayout 是一个自定义导航栏。导航栏下方是一个滚动视图,有许多单元格(标签、条目、选择器)。
我在Android中实现是OK的。 但是在iOS中存在问题:阴影效果不能覆盖一些控件,例如:Entry、Editor、Picker。你能分享我如何解决它吗? 这是 Xamarin.iOS 项目中的代码。
public class DropShadowEffect : PlatformEffect
{
protected override void OnAttached()
{
try
{
var effect = (myDemo.UIControls.DropShadowEffect)Element.Effects.FirstOrDefault(e => e is myDemo.UIControls.DropShadowEffect);
if (effect != null)
{
Container.Layer.CornerRadius = effect.Radius;
Container.Layer.ShadowColor = UIColor.Red.CGColor;// effect.Color.ToCGColor();
Container.Layer.ShadowOffset = new CGSize(effect.DistanceX, effect.DistanceY);
Container.Layer.ShadowOpacity = 0.8f;
Container.Layer.ShadowRadius = 2f;
Container.Layer.ShouldRasterize = true;
Container.Layer.MasksToBounds = false;
}
}
catch (Exception ex)
{
Console.WriteLine("Cannot set property on attached control. Error: {0}", ex.Message);
}
}
*阴影效果过度Label是可以的
*阴影效果不能覆盖 Picker 或 Entry
【问题讨论】:
标签: ios xamarin.forms xamarin.ios effects dropshadow