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


C# UIButton.ViewWithTag方法代码示例

本文整理汇总了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;
		}
开发者ID:MGohil,项目名称:Xamarin-iOS-CollapsibleListView,代码行数:53,代码来源:CollapsibleListView.cs


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