Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在xamarin表单中自定义ZXingDefaultOverlay_C#_Xamarin.forms - Fatal编程技术网

C# 如何在xamarin表单中自定义ZXingDefaultOverlay

C# 如何在xamarin表单中自定义ZXingDefaultOverlay,c#,xamarin.forms,C#,Xamarin.forms,我为扫描视图添加了ZXingDefaultOverlay 我的代码是 <Forms:ZXingDefaultOverlay Grid.Row="1" BackgroundColor="Transparent"/> public class CustomOverlay : ZXingDefaultOverlay { public CustomOverlay() { foreach (var child in Childr

我为扫描视图添加了
ZXingDefaultOverlay

我的代码是

<Forms:ZXingDefaultOverlay Grid.Row="1" BackgroundColor="Transparent"/>
public class CustomOverlay : ZXingDefaultOverlay
    {
        public CustomOverlay()
        {
            foreach (var child in Children.OfType<BoxView>())
            {
                if (child == Children[2])
                {
                    child.BackgroundColor = StatusColorPalette.Success;
                    Margin = new Thickness(50, 0);
                }

                else
                {
                    child.Opacity = 0;
                }
            }
        }
    }

如上图所示,它在扫描仪视图上添加了黑色遮罩


如何避免这种情况?

我通过继承
ZXingDefaultOverlay
创建了
CustomOverlay

我的代码是

<Forms:ZXingDefaultOverlay Grid.Row="1" BackgroundColor="Transparent"/>
public class CustomOverlay : ZXingDefaultOverlay
    {
        public CustomOverlay()
        {
            foreach (var child in Children.OfType<BoxView>())
            {
                if (child == Children[2])
                {
                    child.BackgroundColor = StatusColorPalette.Success;
                    Margin = new Thickness(50, 0);
                }

                else
                {
                    child.Opacity = 0;
                }
            }
        }
    }
公共类CustomOverlay:ZXingDefaultOverlay
{
公共自定义覆盖()
{
foreach(Children.OfType()中的var child)
{
if(child==Children[2])
{
child.BackgroundColor=StatusColorPalette.Success;
余量=新厚度(50,0);
}
其他的
{
不透明度=0;
}
}
}
}
用这个

<Scan:CustomOverlay Grid.Row="1"/>

同样,我们可以定制覆盖