2

I want to do something similar to the crop feature present in the Photos app. I have a background image and over that image I am adding the crop square image using the following code.

   func imageWithBorderFromImage(sourceImage:UIImage,boxImage:UIImage)->UIImage{
        let size = sourceImage.size
        UIGraphicsBeginImageContext(size)
        let rect = CGRectMake(0, 0, size.width, size.height)
        sourceImage.drawInRect(rect, blendMode: CGBlendMode.Normal, alpha: 1.0)
        boxImage.drawInRect(rect, blendMode: CGBlendMode.Normal, alpha: 1.0)
        let testImg =  UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return testImg
    }

I get an output like this:

enter image description here

But these two images become a single image. I want the top crop square to be independent of the below image, so that I can drag it without moving the below image. Is it possible to draw an image over another image such that both images are independent of each other? I am using Swift 2.

JMS
  • 271
  • 4
  • 15

0 Answers0