UICollisionBehavior treats open path as closed?

If I define an open UIBezierPath and set it as a collision boundary:

_containerPath = [UIBezierPath bezierPathWithArcCenter:center
                                                radius:radius
                                            startAngle:M_PI
                                              endAngle:0
                                             clockwise:NO];

[_collisionBehavior addBoundaryWithIdentifier:@"containerBoundary" forPath:_containerPath];                                                     

and then turn gravity on, objects that are released inside the "bowl" respect the lower boundary, but objects released from above the bowl come to rest on the supposedly non-existent side. Is this expected behavior?

In the picture, the red rectangle was dropped from above; the reference view for the dynamic animator is the light gray rect. It fell from above and stopped at the invisible line.

I've confirmed that if you flip the bezier path over, the red rect does in fact respect the curved boundary; I've also tried this using an open (two-sided) triangle instead of curved path - same result.


The behavior you're seeing seems to be the same as what you see for fill with a bezier path. If you draw a "V" and fill it, it behaves as if it were a closed path. With the collision boundaries, you can make an open "V" by adding two lines with addBoundaryWithIdentifier:fromPoint:toPoint:. I don't know it there's any other way around the problem. For your half circle, I presume you could approximate it with a series of straight lines added with the method above. I've approximated circles before using 50 to 100 lines that look very close to what you get with BezierPathWithOvalInRect. I don't know if this creates a serious burden on the system when used as a collision boundary.

链接地址: http://www.djcxy.com/p/96790.html

上一篇: UIKit Dynamics iOS控制中心

下一篇: UICollisionBehavior将开放路径视为已关闭?