Esempio n. 1
0
        public static UIImage CropByX(this UIImage image, nfloat x)
        {
            UIGraphics.BeginImageContextWithOptions(new CGSize(image.Size.Width - x, image.Size.Height), false, 0);

            UIImage result = null;

            using (CGContext context = UIGraphics.GetCurrentContext())
            {
                context.TranslateCTM(0, image.Size.Height);
                context.ScaleCTM(1, -1);

                context.DrawImage(new CGRect(CGPoint.Empty, image.Size), image.CGImage);

                using (CGImage img = context.AsBitmapContext().ToImage())
                {
                    result = new UIImage(img, image.CurrentScale, UIImageOrientation.Up);
                    img.Dispose();
                }

                context.Dispose();
                UIGraphics.EndImageContext();
            }

            return(result);
        }