加载视图控制器时,我正在构建 2 个矩形,使用CGPath. 矩形可以用 移动PanGestureRecognizer。问题是我怎么知道 2 rects 何时相遇?为了不让它们相交?
主视图控制器.m
- (void)viewDidLoad
{
    [super viewDidLoad];
    for (int i=0; i< 2; i++) {
        //create rects of CGPath
        CGRectCustomView* randomColorRect = 
                                [[CGRectCustomView alloc]initWithFrame: 
                                CGRectMake(<random place on screen>)];
        //random angle
        randomColorRect.transform = 
                                CGAffineTransformMakeRotation
                                (DegreesToRadians([Shared randomIntBetween:0 and:360]));
        [self.view addSubview:randomColorRect];
    }
}
- (BOOL)areRectsCollide {
      ???How to find this???
}
CGRectCustomView.m:
- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(context, 8.0); 
    CGContextStrokePath(context); // do actual stroking
    CGContextSetRGBFillColor(context, <green color>, 1); 
    CGContextFillRect(context, CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height)); 
    path = CGContextCopyPath(context);
}
在此处的Apple 指南中,有一个函数可以确定路径是否包含点
- (BOOL)containsPoint:(CGPoint)point onPath:(UIBezierPath *)path inFillArea:(BOOL)inFil,
但我有一个矩形,它的点数是无穷无尽的。所以我该怎么做?打破我的头...