1

I know how to clear the imageView when panning but when I do it clears the image with sharp edges but what I want is to clear the ImageView with soft/smooth edges when panning on the ImageView in iOS using Swift3 ? Hope I am clear with my question.

//For clearing the imageView I use this method.

 func draw(fromPoint:CGPoint,toPoint:CGPoint) {

        if draw {

            UIGraphicsBeginImageContext(self.viewBelowScrollView.bounds.size)// ??
            let context = UIGraphicsGetCurrentContext()
            frontImageView.image?.draw(in: self.viewBelowScrollView.bounds)
            context?.setLineCap(CGLineCap.round)
            context?.setLineWidth(CGFloat(sizeSliderOutlet.value))

            context?.move(to: CGPoint(x: fromPoint.x, y: fromPoint.y))
            context?.addLine(to: CGPoint(x: toPoint.x, y: toPoint.y))
            context?.setBlendMode(CGBlendMode.clear)
            //Setting the Line Configuration
            context?.strokePath()
            //Setting all the things done on the Image View Now.
            frontImageView.image = UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()

        }
    }

//Any help will be highly appreciated. Thank you in advance.

Swifty Codes
  • 992
  • 10
  • 23

1 Answers1

0

try making imageview's clipsToBounds to true, also make imageview's layer's cornerRadius to desired size for corner smoothness.

Sanniv
  • 1,892
  • 1
  • 17
  • 21
  • Thank you fro the reply, My ImageView's clipToBound property is set to TRUE already. from the property inspector. I'll be very glad if you can provide me a demo project for the same. – Swifty Codes Sep 12 '17 at 04:50