当前位置: 首页>>代码示例>>C#>>正文


C# UIButton.SetAccessibilityId方法代码示例

本文整理汇总了C#中UIButton.SetAccessibilityId方法的典型用法代码示例。如果您正苦于以下问题:C# UIButton.SetAccessibilityId方法的具体用法?C# UIButton.SetAccessibilityId怎么用?C# UIButton.SetAccessibilityId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIButton的用法示例。


在下文中一共展示了UIButton.SetAccessibilityId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Title = "Credit Card Validation";
            View.BackgroundColor = UIColor.White;


            var frame = new RectangleF(10, 130, 300, 30);

            _creditCardTextField = new UITextView(frame);
            _creditCardTextField.SetAccessibilityId("CreditCardTextField");
            _creditCardTextField.Layer.BorderColor = UIColor.Black.CGColor;
            _creditCardTextField.Layer.BorderWidth = 0.5f;
            _creditCardTextField.Layer.CornerRadius = 5f;
            _creditCardTextField.Font = UIFont.SystemFontOfSize(16);
            _creditCardTextField.TextContainer.MaximumNumberOfLines = 1;
            _creditCardTextField.KeyboardType = UIKeyboardType.NumberPad;

            _validateButton = new UIButton(new RectangleF(10, 165, 300, 40));
            _validateButton.SetTitle("Validate Credit Card", UIControlState.Normal);
            _validateButton.SetAccessibilityId("ValidateButton");
            _validateButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            _validateButton.BackgroundColor = UIColor.FromRGB(52, 152, 219);
            _validateButton.Layer.CornerRadius = 5;

            _errorMessagesTextField = new UILabel(new RectangleF(10, 210, 300, 40));
            _errorMessagesTextField.SetAccessibilityId("ErrorMessagesTextField");
            _errorMessagesTextField.Text = String.Empty;

            _validateButton.TouchUpInside += (object sender, EventArgs e) =>{
                                                 _errorMessagesTextField.Text = String.Empty;

                                                 // perform a simple "required" validation
                                                 string errMessage;
                                                 if (!IsCCValid(out errMessage))
                                                 {
                                                     // need to update on the main thread to change the border color
                                                     InvokeOnMainThread(() =>{
                                                                            _creditCardTextField.BackgroundColor = UIColor.Yellow;
                                                                            _creditCardTextField.Layer.BorderColor = UIColor.Red.CGColor;
                                                                            _creditCardTextField.Layer.BorderWidth = 3;
                                                                            _creditCardTextField.Layer.CornerRadius = 5;
                                                                            _errorMessagesTextField.Text = errMessage;
                                                                        });
                                                 }
                                                 else
                                                 {
                                                     NavigationController.PushViewController(new CreditCardValidationSuccess(), true);
                                                 }
                                             };

            View.Add(_creditCardTextField);
            View.Add(_validateButton);
            View.Add(_errorMessagesTextField);
        }
开发者ID:IanLeatherbury,项目名称:mini-hacks,代码行数:55,代码来源:CreditCardValidationScreen.cs


注:本文中的UIButton.SetAccessibilityId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。