本文整理汇总了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;
}
示例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( );
}