本文整理汇总了C#中UIButton.ViewWithTag方法的典型用法代码示例。如果您正苦于以下问题:C# UIButton.ViewWithTag方法的具体用法?C# UIButton.ViewWithTag怎么用?C# UIButton.ViewWithTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIButton
的用法示例。
在下文中一共展示了UIButton.ViewWithTag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetViewForHeader
public override UIView GetViewForHeader (UITableView tableView, nint section)
{
var btn = new UIButton (new CGRect (0, 0, tableView.Frame.Width, CollapsibleListViewCell.HEIGHT));
btn.TitleEdgeInsets = new UIEdgeInsets (btn.TitleEdgeInsets.Top, CollapsibleListViewCell.ParentItemLeftPadding, btn.TitleEdgeInsets.Bottom, btn.TitleEdgeInsets.Right);
btn.AutoresizingMask = UIViewAutoresizing.All;
//set section header right side image
if (!string.IsNullOrEmpty (Settings [(int)section].SelectedStateIcon) && !string.IsNullOrEmpty (Settings [(int)section].DeselectedStateIcon)) {
var btnImg = btn.ViewWithTag ((int)section);
if (btnImg != null) {
btnImg.RemoveFromSuperview ();
}
var img = !Settings [(int)section].IsSelected ? new UIImageView (UIImage.FromBundle (Settings [(int)section].DeselectedStateIcon)) : new UIImageView (UIImage.FromBundle (Settings [(int)section].SelectedStateIcon));
img.Tag = (int)section;
img.Frame = new CGRect (
btn.Frame.Width - CollapsibleListViewCell.HEIGHT - 20,
0,
CollapsibleListViewCell.HEIGHT,
CollapsibleListViewCell.HEIGHT
);
img.ContentMode = UIViewContentMode.Center;
img.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin;
//img.BackgroundColor = UIColor.Yellow;
btn.AddSubview (img);
}
//ADD SEPERATOR LINE AT BOTTOM
var seperatorLine = new UIView (new CGRect (0, CollapsibleListViewCell.HEIGHT - 1, tableView.Frame.Width, 1));
seperatorLine.BackgroundColor = UIColor.LightGray;
seperatorLine.Alpha = 0.3f;
seperatorLine.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
btn.AddSubview (seperatorLine);
btn.SetTitle (Settings [(int)section].Title, UIControlState.Normal);
btn.Font = UIFont.BoldSystemFontOfSize (CollapsibleListViewCell.FontSize);
btn.BackgroundColor = UIColor.Clear;
btn.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
btn.SetTitleColor (UIColor.DarkGray, UIControlState.Normal);
btn.TouchUpInside += (sender, e) => {
//put in your code to toggle your boolean value here
if (Settings [(int)section].OnClickListener != null) {
Settings [(int)section].OnClickListener.Invoke (Settings [(int)section]);
}
Settings [(int)section].IsSelected = !Settings [(int)section].IsSelected;
///reload this section
tableView.ReloadSections (NSIndexSet.FromIndex (section), UITableViewRowAnimation.Fade);
};
return btn;
}