I have a custom UIButton
in which I draw a circle using CAShapeLayer
. The button is used later in conjunction with UICollisionBehavior
to detect collision between several UIButtons
. However, I suppose the UICollisionBehavior detects the bounding box of the button, which is a square. Is there a way to make the bounding box equal to the drawn shape?
This is the snippet I used for drawing the button:
let circlePath = UIBezierPath(arcCenter: CGPoint(x: self.diameter! / 2.0, y: self.diameter! / 2.0), radius: (self.diameter! - 10)/2, startAngle: 0.0, endAngle: CGFloat(M_PI * 2.0), clockwise: true)
circleLayer = CAShapeLayer()
circleLayer.path = circlePath.CGPath
circleLayer.fillColor = UIColor.redColor().CGColor
circleLayer.strokeEnd = 1.0
self.layer.addSublayer(circleLayer)