im试图创建一个内部带有透明孔的覆盖层。 当出现叠加层时,圆圈应稍微弹起,然后移至视图底部。
我创建了圆并尝试添加动画和运动,但是什么也没有发生,圆不动。
这是我的代码:
let overlay = UIView(frame: (self.view?.bounds)!)
let radius: CGFloat = 60.0
let circleFrame = CGRect(x: (self.view?.bounds.size.width)!/2, y: (self.view?.bounds.size.height)!/2, width: radius, height: radius)
let path = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: (self.view?.bounds.size.width)!, height: (self.view?.bounds.size.height)!), cornerRadius: 0)
let circlePath = UIBezierPath(roundedRect: circleFrame, cornerRadius: radius)
path.append(circlePath)
path.usesEvenOddFillRule = true
let fillLayer = CAShapeLayer()
fillLayer.path = path.cgPath
fillLayer.fillRule = kCAFillRuleEvenOdd
fillLayer.fillColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.7).cgColor
overlay.layer.addSublayer(fillLayer)
self.view?.addSubview(overlay)
circlePath.apply(CGAffineTransform(translationX: 50, y: 50))
circlePath.stroke()
有人可以帮忙吗?谢谢。