如何清除ImageView?

时间:2017-09-08 09:07:55

标签: ios iphone swift ios8 xcode8

我知道如何在平移时清除imageView,但是当我这样做时会清除带有锐边的图像但是我想要的是在使用Swift3在iOS上的ImageView上平移时用软/光滑的边缘清除ImageView?希望我对我的问题很清楚。

//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()

        }
    }

//将非常感谢任何帮助。提前谢谢。

1 个答案:

答案 0 :(得分:0)

尝试将imageview' s clipsToBounds设为true,同时将imageview的图层cornerRadius设置为所需的角度平滑度。