2

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)
user3607973
  • 345
  • 1
  • 5
  • 15
  • possible duplicate of [UIDynamicItem with non-rectangular bounds](http://stackoverflow.com/questions/22000703/uidynamicitem-with-non-rectangular-bounds) – thelaws Apr 17 '15 at 19:55
  • @thelaws Thanks. So I suppose it won't work. Apparently only with `SpriteKit` – user3607973 Apr 17 '15 at 20:14

0 Answers0