partial void AddButtonClickHandler(NSObject sender) { // Create a random dummy image. var rect = new Random().Next(0, 2) == 0 ? new CGRect(0f, 0f, 400f, 300f) : new CGRect(0f, 0f, 300f, 400f); UIGraphics.BeginImageContextWithOptions(rect.Size, false, 1f); UIColor.FromHSBA(new Random().Next(0, 100) / 100f, 1f, 1f, 1f).SetFill(); UIGraphics.RectFillUsingBlendMode(rect, CGBlendMode.Normal); UIImage image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); // Add it to the photo library PHPhotoLibrary.SharedPhotoLibrary.PerformChanges(() => { PHAssetChangeRequest assetChangeRequest = PHAssetChangeRequest.FromImage(image); if (AssetCollection != null) { PHAssetCollectionChangeRequest assetCollectionChangeRequest = PHAssetCollectionChangeRequest.ChangeRequest(AssetCollection); assetCollectionChangeRequest.AddAssets(new PHObject[] { assetChangeRequest.PlaceholderForCreatedAsset }); } }, (success, error) => { if (!success) { Console.WriteLine(error.LocalizedDescription); } }); }