Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.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
Mono 在所有UIXamarin按钮周围创建一个边框_Mono_Xamarin - Fatal编程技术网

Mono 在所有UIXamarin按钮周围创建一个边框

Mono 在所有UIXamarin按钮周围创建一个边框,mono,xamarin,Mono,Xamarin,我在iOS应用程序中使用Xamarin大约有10个按钮,我正在寻找一种简单的方法,在我所有的按钮周围放置一个黑色边框。有没有一种方法可以在不将边框硬编码到所有按钮中的情况下实现这一点 到目前为止,我在一个按钮周围放置了一个边框: numOne.Layer.BorderWidth = 1; numOne.Layer.CornerRadius = 4; numOne.Layer.BorderColor = UIColor.Black.CGColor; 对于我所有的按钮,有什么方法可以做到这一点吗?

我在iOS应用程序中使用Xamarin大约有10个按钮,我正在寻找一种简单的方法,在我所有的按钮周围放置一个黑色边框。有没有一种方法可以在不将边框硬编码到所有按钮中的情况下实现这一点

到目前为止,我在一个按钮周围放置了一个边框:

numOne.Layer.BorderWidth = 1;
numOne.Layer.CornerRadius = 4;
numOne.Layer.BorderColor = UIColor.Black.CGColor;

对于我所有的按钮,有什么方法可以做到这一点吗?

制作自己的按钮类

(这段代码只是我脑海中的一部分,没有在IDE中进行测试)


制作自己的按钮类

(这段代码只是我脑海中的一部分,没有在IDE中进行测试)


制作自己的按钮类

(这段代码只是我脑海中的一部分,没有在IDE中进行测试)


制作自己的按钮类

(这段代码只是我脑海中的一部分,没有在IDE中进行测试)


或者您可以创建一个返回首选按钮的方法:

public static class DefaultUIElements
{
    public static UIButton GenericButton
    {
        get
        {
            UIButton button = new UIButton(UIButtonType.Custom);
            button.Layer.BorderWidth = 1;
            button.Layer.CornerRadius = 4;
            button.Layer.BorderColor = UIColor.Black.CGColor;
            return button;
        }
    }
}

或者您可以创建一个返回首选按钮的方法:

public static class DefaultUIElements
{
    public static UIButton GenericButton
    {
        get
        {
            UIButton button = new UIButton(UIButtonType.Custom);
            button.Layer.BorderWidth = 1;
            button.Layer.CornerRadius = 4;
            button.Layer.BorderColor = UIColor.Black.CGColor;
            return button;
        }
    }
}

或者您可以创建一个返回首选按钮的方法:

public static class DefaultUIElements
{
    public static UIButton GenericButton
    {
        get
        {
            UIButton button = new UIButton(UIButtonType.Custom);
            button.Layer.BorderWidth = 1;
            button.Layer.CornerRadius = 4;
            button.Layer.BorderColor = UIColor.Black.CGColor;
            return button;
        }
    }
}

或者您可以创建一个返回首选按钮的方法:

public static class DefaultUIElements
{
    public static UIButton GenericButton
    {
        get
        {
            UIButton button = new UIButton(UIButtonType.Custom);
            button.Layer.BorderWidth = 1;
            button.Layer.CornerRadius = 4;
            button.Layer.BorderColor = UIColor.Black.CGColor;
            return button;
        }
    }
}