xamarin.ios是否有切换按钮?如果不是,更好的方法是使用两个按钮并切换其“隐藏”属性?
谢谢
最佳答案
解决您的问题:
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
UIButton btnPlayAndStop = new UIButton (new CGRect (100, 100, 50, 50));
btnPlayAndStop.BackgroundColor = UIColor.Gray;
btnPlayAndStop.Tag = 0;
btnPlayAndStop.SetImage (UIImage.FromFile ("play.png"), UIControlState.Normal);
btnPlayAndStop.TouchUpInside += delegate {
if (0 == btnPlayAndStop.Tag) {
btnPlayAndStop.Tag = 1;
btnPlayAndStop.SetImage (UIImage.FromFile ("stop.png"), UIControlState.Normal);
}
else if (1 == btnPlayAndStop.Tag) {
btnPlayAndStop.Tag = 0;
btnPlayAndStop.SetImage (UIImage.FromFile ("play.png"), UIControlState.Normal);
}
};
this.View.AddSubview (btnPlayAndStop);
}
希望它能对您有所帮助。
任何有关Xamarin.iOS的问题都欢迎。
关于ios - Xamarin.IOS切换按钮?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32316190/