我试图添加形状。但我无法弯曲边缘
func setUpView() {
let rightRandomPoint = CGPoint(x: view.bounds.width, y: CGFloat(arc4random_uniform(UInt32(UIScreen.main.bounds.height))))
let bottomRandomPoint = CGPoint(x: CGFloat(arc4random_uniform(UInt32(view.bounds.width))), y: UIScreen.main.bounds.height)
shapeLayer.frame = CGRect(x: rightRandomPoint.x - (rightRandomPoint.x / 6), y: bottomRandomPoint.y - (bottomRandomPoint.y / 2.5), width: view.bounds.width / 6.01, height: view.bounds.height / 3.3)
shapeLayer.backgroundColor = UIColor.black.cgColor
shapeLayer.path = UIBezierPath(ovalIn: shapeLayer.frame).cgPath
shapeLayer.cornerRadius = shapeLayer.frame.height / 2
//self.roundCorners(view: shapeLayer, corners: [.topLeft], radius: 1300)
view.layer.addSublayer(shapeLayer)
print("right x :: \(rightRandomPoint)")
print("bottum y :: \(bottomRandomPoint)")
//view.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: "panGestureDidMove:"))
}
func roundCorners(view :CAShapeLayer, corners: UIRectCorner, radius: CGFloat){
let path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
let mask = CAShapeLayer()
mask.path = path.cgPath
view.mask = mask
}
需要创建图像中的形状