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


C# UIButton.SetNeedsDisplay方法代码示例

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


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

示例1: TestView

		public UIViewController TestView()
		{
			// Create a view with a Button to run the tests and a Text View for the Results.
			var vc = new UIViewController();
			
			var btn = new UIButton(new RectangleF(0, 0, 100, 40));
			btn.SetTitle("Run Tests", UIControlState.Normal);
			btn.BackgroundColor = UIColor.White;
			btn.SetTitleColor(UIColor.Black, UIControlState.Normal);
			
			var textResults = new UITextView(new RectangleF(0, 50, vc.View.Bounds.Width, 40));
			textResults.Text = "";
			textResults.Hidden = true;
			
			// Setup Test here
			btn.TouchUpInside += (sender, e) => 
			{
				Console.WriteLine("Running Tests...");
				textResults.Text = "Tests Running";
			 	btn.Enabled = false;
				
				textResults.SetNeedsDisplay();
				btn.SetNeedsDisplay();
				
				try	
				{	
					var results = RunTests();
					
					var failed = results.Where(r => !r.Pass).ToList();
					
					textResults.Text = failed.Count == 0 ? "All Filters Passed" : "These filters failed " + string.Join(Environment.NewLine, failed.Select (r => r.FilterName));
					textResults.Hidden = false;
				}
				finally
				{
					btn.Enabled = true;
				}
			};
			
			vc.View.AddSubviews(btn, textResults);
			
			return vc;
		}
开发者ID:robertgreen,项目名称:monotouch-samples,代码行数:43,代码来源:AppDelegate.cs

示例2: PersonEntry

                    public PersonEntry( string personName, int personId, bool canCheckin, string roleInFamily, List<Rock.Client.GroupMember> primaryFamilyMembers )
                    {
                        PrimaryFamilyMembers = primaryFamilyMembers;

                        PersonId = personId;

                        CanCheckin = canCheckin;

                        Button = new UIButton( UIButtonType.System );
                        Button.Layer.AnchorPoint = CGPoint.Empty;
                        Button.Layer.CornerRadius = 4;
                        Button.Bounds = new CGRect( 0, 0, PersonEntryWidth, PersonEntryHeight );

                        Name = new UILabel( );
                        Name.Layer.AnchorPoint = CGPoint.Empty;
                        Name.Text = personName;
                        Name.SizeToFit( );
                        Name.TextColor = Theme.GetColor( Config.Instance.VisualSettings.PrimaryButtonStyle.TextColor );
                        Button.AddSubview( Name );

                        AgeLabel = new UILabel( );
                        AgeLabel.Layer.AnchorPoint = CGPoint.Empty;
                        AgeLabel.Text = roleInFamily;
                        AgeLabel.TextColor = Theme.GetColor( Config.Instance.VisualSettings.PrimaryButtonStyle.TextColor );
                        AgeLabel.Font = FontManager.GetFont( Settings.General_LightFont, Config.Instance.VisualSettings.SmallFontSize );
                        AgeLabel.SizeToFit( );
                        Button.AddSubview( AgeLabel );

                        nfloat combinedHeight = Name.Layer.Bounds.Height + AgeLabel.Bounds.Height;
                        nfloat startingY = (PersonEntryHeight - combinedHeight) / 2;

                        Name.Layer.Position = new CGPoint( (PersonEntryWidth - Name.Bounds.Width) / 2, startingY );
                        AgeLabel.Layer.Position = new CGPoint( (PersonEntryWidth - AgeLabel.Bounds.Width) / 2, Name.Frame.Bottom );

                        Button.TouchUpInside += (object sender, EventArgs e) =>
                            {
                                Button.Enabled = false;

                                // are they currently able to check in?
                                if( CanCheckin == true )
                                {
                                    // then remove it.
                                    int pendingRemovals = 0;
                                    foreach( Rock.Client.GroupMember member in primaryFamilyMembers )
                                    {
                                        FamilyManagerApi.RemoveKnownRelationship( member.Person.Id, PersonId, Config.Instance.CanCheckInGroupRole.Id, delegate
                                            {
                                                // once we hear back from all the requests, toggle the button
                                                pendingRemovals++;

                                                if( pendingRemovals == primaryFamilyMembers.Count )
                                                {
                                                    Button.Enabled = true;
                                                    CanCheckin = !CanCheckin;
                                                    UpdateBGColor( );
                                                    Button.SetNeedsDisplay( );
                                                }
                                            });
                                    }
                                }
                                else
                                {
                                    // simply bind them to the first person
                                    FamilyManagerApi.UpdateKnownRelationship( primaryFamilyMembers[ 0 ].Person.Id, PersonId, Config.Instance.CanCheckInGroupRole.Id, delegate
                                        {
                                            Button.Enabled = true;
                                            CanCheckin = !CanCheckin;
                                            UpdateBGColor( );
                                            Button.SetNeedsDisplay( );
                                        });
                                }
                            };

                        UpdateBGColor( );
                    }
开发者ID:SparkDevNetwork,项目名称:FamilyManager,代码行数:75,代码来源:FamilyInfoViewController.cs


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