是否有xamarin.ios的切换按钮?如果没有,更好的方法是使用两个按钮并切换他们的隐藏属性?
谢谢
答案 0 :(得分:2)
解决您的问题:
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的问题。