您的位置:首页 > 其它

判断一个点是否在view上

2015-07-02 14:19 323 查看
- (void)inArea
{
CGMutablePathRef pathRef = CGPathCreateMutable();
CGPathMoveToPoint(pathRef, NULL, 4, 4);

CGPathAddLineToPoint(pathRef, NULL, 4, 14);

CGPathAddLineToPoint(pathRef, NULL, 14, 14);

CGPathAddLineToPoint(pathRef, NULL, 14, 4);

CGPathAddLineToPoint(pathRef, NULL, 4, 4);

CGPathCloseSubpath(pathRef);

CGPoint point=CGPointMake(5, 5);

CGPoint outPoint=CGPointMake(1, 1);

if (CGPathContainsPoint(pathRef, NULL, point, NO)) { NSLog(@"point in path!");

}

if (!CGPathContainsPoint(pathRef, NULL, outPoint, NO)) { NSLog(@"outPoint out path!");

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: