有可能在Xamarin中模糊背景吗?

5w9g7ksd  于 2023-03-16  发布在  其他
关注(0)|答案(3)|浏览(163)

我尝试了一些方法,但唯一的方法是在github上安装和使用它们。有没有办法简单地在xaml文件中模糊化?
例如
我想模糊网格背景。这可能吗?

mum43rcc

mum43rcc1#

Xamarin中没有内置模糊效果。您需要额外的工具SkiaSharp或Sharpnado。StackOverflow相关问题:
Make current screen into BLUR on Xamarin.forms
另一种方法是创建自己的控件:
https://www.c-sharpcorner.com/article/how-to-create-and-use-a-blurred-image-in-xamarin-forms/

cgyqldqp

cgyqldqp2#

<Grid>
    <Image Source="image.jpg" Aspect="AspectFill" />
    <BoxView Color="#80000000" />
    <controls:Blur BlurType="Gaussian" BlurAmount="12" />
        ----> Rest of your code here <----
</Grid>
6qfn3psc

6qfn3psc3#

是的,你可以使用SkiaSharp image filters。你可以参考这个文档关于模糊矢量图形和位图。

public static SkiaSharp.SKImageFilter CreateBlur (float sigmaX, float sigmaY,
                                                  SKImageFilter input = null,
                                                  SKImageFilter.CropRect cropRect = null);

相关问题