【发布时间】:2020-06-26 14:20:45
【问题描述】:
在我的 Xamarin.Forms 应用中,我有 MaterialFrame 自定义控件。
iOS 渲染器效果很好,看起来像:
public class MaterialFrameRenderer : FrameRenderer
{
private const int ShadowColor = 0x939393;
public override void Draw(
CGRect rect)
{
base.Draw(rect);
// Update shadow to match better material design standards of elevation
Layer.ShadowRadius = Layer.CornerRadius;
Layer.ShadowColor = ColorHelper.FromHex(ShadowColor).CGColor;
Layer.ShadowOffset = new CGSize(1, 1);
Layer.ShadowOpacity = 0.30f;
Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath;
Layer.MasksToBounds = false;
}
}
在 Android 平台上,我想使用基于我的其他跨平台控件的实现。我的 .net 标准(共享项目)实现:
public class MaterialFrame : Frame
{
public MaterialFrame()
{
if (Device.RuntimePlatform == Device.Android)
{
Content = new MyOtherCustomControl
{
BackgroundColor = Color.Red
};
}
}
}
很遗憾,此实现不适用于 Android。你有什么建议吗?
【问题讨论】:
标签: xaml xamarin xamarin.forms