c# – Toast通知Xamarin iOS
我正在为Xamarin(C#)编写iOS应用程序.
在iOS中,Android的“Toast notifications”相当于什么? 从documentation开始:
例如在Android(C#)中,我可以像这样显示它们: Toast.MakeText(this,"Added " + counttext.Text +" pcs to cart",ToastLength.Long).Show(); 我如何为iOS编写相同的内容? 谢谢你的回答. 解决方法
在Xamarin iOS中,您必须使用自定义设计的UIView和动画来实现相同的效果
public void ShowToast(String message,UIView view) { UIView residualView = view.ViewWithTag(1989); if (residualView != null) residualView.RemoveFromSuperview(); var viewBack = new UIView(new CoreGraphics.CGRect(83,300,100)); viewBack.BackgroundColor = UIColor.Black; viewBack.Tag = 1989; UILabel lblMsg = new UILabel(new CoreGraphics.CGRect(0,20,60)); lblMsg.Lines = 2; lblMsg.Text = message; lblMsg.TextColor = UIColor.White; lblMsg.TextAlignment = UITextAlignment.Center; viewBack.Center = view.Center; viewBack.AddSubview(lblMsg); view.AddSubview(viewBack); roundtheCorner(viewBack); UIView.BeginAnimations("Toast"); UIView.SetAnimationDuration(3.0f); viewBack.Alpha = 0.0f; UIView.CommitAnimations(); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |