Esempio n. 1
0
        public Task <IBitmap> LoadFromResource(string source, float?desiredWidth, float?desiredHeight)
        {
            var tcs = new TaskCompletionSource <IBitmap>();

            UIApplication.SharedApplication.InvokeOnMainThread(() => {
                try {
#if UIKIT
                    tcs.TrySetResult(new CocoaBitmap(UIImage.FromBundle(source)));
#else
                    tcs.TrySetResult(new CocoaBitmap(UIImage.ImageNamed(source)));
#endif
                } catch (Exception ex) {
                    tcs.TrySetException(ex);
                }
            });
            return(tcs.Task);
        }