1
votes

I'm playing around with UIKit dynamics, I have two UIImageViews with an UICollisionBehavior, it's delegate is fired when the two views collide, the problem is, if the image is a circle the frame is a square and even the frames are colliding that's not what I really want.

How the collision is detected:

enter image description here

How I want to be detected:

enter image description here

Is there a workaround to achieve this?. Thank you in advance.

UPDATE: The images aren't circles, so I'll probably have to use UIDynamicItemCollisionBoundsTypePath and transform my UIImage to a UIBezierPath

1

1 Answers

3
votes

You should make a subclass of UIImageView and implement:

override var collisionBoundsType: UIDynamicItemCollisionBoundsType {
        return .Ellipse
    }

or

-(UIDynamicItemCollisionBoundsType) collisionBoundsType {
    return UIDynamicItemCollisionBoundsTypeEllipse;
}

For more information see here