2017-09-08 74 views
1

我知道如何在平移時清除imageView,但是當我這樣做時清除了銳利邊緣的圖像,但是我想要的是在使用Swift3在iOS上對ImageView進行平移時,使用柔和/平滑邊緣清除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() 

     } 
    } 

//任何幫助將不勝感激。先謝謝你。

回答

0

嘗試將imageview的clipsToBounds設置爲true,同時使imageview的圖層cornerRadius達到所需的角度平滑度。

+0

謝謝你的回覆,我的ImageView的clipToBound屬性已設置爲TRUE。來自財產督察。如果您能爲我提供相同的演示項目,我將非常高興。 –