I am new to ios. I am trying to make the bottom border(not left of right the whole bottom) of image view into curve. Anyone can guide me how to do it.
I am new to ios. I am trying to make the bottom border(not left of right the whole bottom) of image view into curve. Anyone can guide me how to do it.
You can do this like:
func curvedShapeFor(view: UIImageView, curvedPercent:CGFloat) ->UIBezierPath
{
let path = UIBezierPath()
path.move(to: CGPoint(x:0, y:0))
path.addLine(to: CGPoint(x:view.bounds.size.width, y:0))
path.addLine(to: CGPoint(x:view.bounds.size.width, y:view.bounds.size.height - (view.bounds.size.height*curvedPercent)))
path.addQuadCurve(to: CGPoint(x:0, y:view.bounds.size.height - (view.bounds.size.height*curvedPercent)), controlPoint: CGPoint(x:view.bounds.size.width/2, y:view.bounds.size.height))
path.addLine(to: CGPoint(x:0, y:0))
path.close()
return path
}
And apply like this way:
let shapeLayer = CAShapeLayer(layer: imageView.layer)
shapeLayer.path = self.curvedShapeFor(view: imageView,curvedPercent: 0.6).cgPath
shapeLayer.frame = imageView.bounds
shapeLayer.masksToBounds = true
imageView.layer.mask = shapeLayer