如何在Xamarin Forms中创建投影 [英] How do you create a drop shadow in Xamarin Forms

查看:132
本文介绍了如何在Xamarin Forms中创建投影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Xamarin Forms在按钮或标签上创建阴影.我目前正在使用Xamarin Forms 1.3,并尽可能尝试在XAML中执行此操作.没有人有一个可行的榜样,他们可以向我指出.

How do you create a drop shadow on a button or label using Xamarin Forms. I am currently using Xamarin Forms 1.3 and trying to do this in XAML if possible. Does anyone have a working example they can point me to.

推荐答案

我没有尝试过,但是您可以创建同一控件的2个实例,并将它们放置在网格中,以便它们彼此直接重叠.然后使用第一个控件(在下面)将不透明度更改为0.2,以使其非常微弱,然后为其提供较小的顶部和左侧边缘,使其与上面的版本略有偏移.这将导致阴影类型的效果. 更好(但涉及更多)的方法是将要添加效果的控件子类化,然后创建自定义渲染器以使用本机代码为每个平台添加效果

I have not tried this but you could create 2 instances of the same control and put them both inside a grid so that they lay directly over each other. Then with the first control (underneath) change the opacity to 0.2 so that it is very faint, then give it a small top and left margin so it sits slightly offset from the version above it. This should result in a drop-shadow type of effect. A much better (but more involved) way of doing this is to subclass the controls you want to add the effect to and then create custom renderers to add the effect for each platform using native code

这篇关于如何在Xamarin Forms中创建投影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆