【发布时间】:2016-05-08 17:14:28
【问题描述】:
我可以像这样检测到 CAShapeLayer 的触摸 (touchesEnded):
let touchLocation : CGPoint = (touch as! UITouch).locationInView(self.view)
for shape in shapes{
if CGPathContainsPoint(shape.path, nil, touchLocation, false){
print("Layer touch")
}
}
我可以像这样为 CAShapeLayer 的路径设置动画:
let newShapePath = UIBezierPath(arcCenter: toPoint, radius: 20, startAngle: CGFloat(0), endAngle: CGFloat(M_PI * 2), clockwise: true).CGPath
// animate the `path`
let animation = CABasicAnimation(keyPath: "path")
animation.toValue = newShapePath
animation.duration = CFTimeInterval(duration)
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
animation.fillMode = kCAFillModeBoth
animation.removedOnCompletion = false
shape.addAnimation(animation, forKey: animation.keyPath)
但是当动画发生时,在 CAShapeLayer 上没有检测到触摸。是否可以在为路径设置动画时检测到 CAShapeLayer 上的触摸?
【问题讨论】:
标签: ios swift core-animation cashapelayer cabasicanimation