C# Xamarin iOS寫法
首先打開你的AppDelegate
然後在裡面先宣告一下UIImageView
private static UIImageView MybgImg;
當iOS進行背景時會呼叫LifeCycle中的DidEnterBackground的method,下一步要在裡面加入以下程式碼
MybgImg = new UIImageView(UIScreen.MainScreen.Bounds);//設定圖片的尺寸
MybgImg.Image = UIImage.FromBundle("assets/landscape.png");//選擇一個圖片
this.Window.AddSubview(MybgImg);//覆蓋主畫面
最後一步,當你從背景跳回前景時會呼叫LifeCycle中的WillEnterForeground的method
MybgImg.RemoveFromSuperview();//移除主畫面所覆蓋的圖片
可以避免iOS螢幕snapshot的cache裡不會有行動應用程式主畫面的資訊。