判断一个点是否在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!");
}
}
{
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!");
}
}
相关文章推荐
- php 加密 解密 方法
- ContentObserver 介绍
- Cloudfoundry之Service
- JPush推送 之 RegistrationID 精确对点推送
- 【Android基础篇】TabWidget设置背景和字体
- 配置Odroid ubunutu 静态IP 并让PC 使用Ccproxy 做代理上网
- SecureCRT快捷键
- 实时操作系统与非实时操作系统到底有什么区别?
- 在ActionBar中进行Fragment之间的切换
- Android版本和API Level对应关系
- iOS开发各种小知识
- Scala学习笔记三
- struct和class的区别
- Android对SQLite批量添加数据
- SQL Server 存储过程
- sql 升序 ,降序
- rhel6上系列系统安装zabblix系统监控
- android使用startActivityForResult多级回传参数
- PL/SQL TABLE 表达式
- VC CComboBox用法