mono touch中UISwitch控件的使用

来源:互联网 发布:数据库 王珊 答案 编辑:程序博客网 时间:2024/06/12 01:02
有不明白的地方欢迎入群 347636249 探讨
using System;//using MonoTouch.UIKit;using MonoTouch.Foundation;using System.Drawing;namespace GCForum{public class MyTestVC :UIViewController{public MyTestVC (){}private UISwitch _switch;public override void ViewDidLoad (){base.ViewDidLoad ();this.View.BackgroundColor = UIColor.White;UILabel lbl = xxxx.ControlCenter.CreateLbl (new RectangleF (10, 100, 100, 20), "");this.View.Add (lbl);_switch = new UISwitch {BackgroundColor = UIColor.Red,Frame = new RectangleF (new PointF(10,10),SizeF.Empty)};_switch.SetState (true, false); //默认设置on选项_switch.ValueChanged += delegate {lbl.Text=_switch.On.ToString();};this.View.Add (_switch);}//...}}

关键是ValueChanged方法,另外,虽然说UISwitch是继承于UIControl,但它的大小是固定的,你即便设置了它的大小,显示不会有变化。


0 0
原创粉丝点击