Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gwelmarten

macrumors 6502
Original poster
Jan 17, 2011
476
0
England!
I've got a class that creates a UIView, which is a 100x150px rectangle. That UIView contains a UIImageView, which is 100x100.

At the moment, I use UICollisionBehaviour between the UIViews, and this means all objects collide as if they are rectangles, which looks ridiculous as my UIView is a circle at the top, then a small label at the bottom, and the rest is transparent.

I can't see how to add a collision boundary to a UIView (to represent the part of it that is collidable), or if this is even possible. Is this possible?

As far as I'm aware, I can't just carry out collision detection between the UIImageView's either, as they are not moving (i.e. they're static within their UIView), and of course they can't change the position of the parent UIView.

Is it possible to do this with UIKitDynamics? I can't seem to find it in the docs anywhere, but I've seen examples of custom collision bounds, with falling UIImageViews of a ball shape, using set custom bounds and trip to bounds. Obviously I'm keen to avoid converting the whole app to SpriteKit.

Thanks in advance for any help!

Sam
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.