- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在编写 Swift 应用程序,我使用 SDK Skobbler 来操作 map 。应用程序显示圆圈:
func displayCircle(x: Int, y: Int, radius: Int){...} //display circle in the map
此外,我检查用户是否在这个区域:
for area in self.areas {
var c = UIBezierPath()
let lat = area.getLatitude()
let long = area.getLongitude()
let radius = area.getRadius()/1000
let center = CGPoint(x: lat, y: long)
c.addArcWithCenter(center, radius: CGFloat(radius), startAngle: CGFloat(0), endAngle: CGFloat(360), clockwise: true)
if c.containsPoint(CGPoint(x: currentLocation.latitude, y: currentLocation.longitude)) {
//I AM IN THE AREA
}else {
//I AM NOT IN THE AREA
}
c.closePath()
}
当我在圈子里时,它有效,但当我在圈子外时,它也有效...
我认为问题与单位半径有关
谢谢你的帮助
是的
最佳答案
iOS单位是点。
在非视网膜设备中,1 个点等于 1 个像素。在视网膜设备 (@2x) 中,1 点等于两个像素。在@3x 设备(Iphone 6 plus)中,1 点等于 3 个像素。
注意角度。单位是弧度不是度。所以你需要将你的度数转换为弧度,你的和角度应该是 2 * M_PI
对应于 360 度。您可以定义一个扩展来进行转换:
extension Int {
var degreesToRadians : CGFloat {
return CGFloat(self) * CGFloat(M_PI) / 180.0
}
}
45.degreesToRadians // 0.785398163397448
关于ios - UIBezierPath - 什么是单位半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32399822/
我有两个 UIBezierPath,一个表示图像的多边形部分,另一个是要在其上绘制的路径。 我需要找到它们之间的交点,以便只有在这个交点区域内的点才会被着色。 UIBezierPath 中是否有一种方
我正在制作一个应用程序,允许用户用手指在屏幕上绘制不同的颜色。图纸是用 UIBezierPaths 绘制的,但我需要橡皮擦。我确实有一个橡皮擦,它只是一条以背景图像为颜色的路径,但这种方法会导致内存问
我想用 SceneKit 画一条贝塞尔曲线,并认为这会起作用: func drawCurvedLine() { let scene = SCNScene() let scnView =
我在设置为 iPhone (Retina 4-inch) 的模拟器中运行此代码 -(void)drawRect:(CGRect)rect { [[UIColor whiteColor]set]
我想绘制月亮,然后为月亮的阴影设置动画。但启动此代码后,我可以在动画线上看到一些故障: GIF: 为什么会发生这种情况? Playground 代码 here 更新1:此函数创建的两条路径具有不同的角
假设我们有一个 UIBezierPath...它的边界是完全正方形的...像这样: func getExponentPath(rotate180: Bool) -> UIBezierPath {
我想绘制月亮,然后为月亮的阴影设置动画。但启动此代码后,我可以在动画线上看到一些故障: GIF: 为什么会发生这种情况? Playground 代码 here 更新1:此函数创建的两条路径具有不同的角
假设我们有一个 UIBezierPath...它的边界是完全正方形的...像这样: func getExponentPath(rotate180: Bool) -> UIBezierPath {
我正在试验 UIBezierPath。我想做一个 GridView 。 NSInteger yAxisIncremental = 0; NSInteger xAxisIncremental = 0;
我需要使用bezeirPath绘制此形状: 我做了以下事情: 我创建了矩形路径。 然后我添加了五个圈子。 如下面的代码所示: let stickLayerBezeirPath = UIBezierPa
我将 Apple 文档阅读到 UIBezierPath目的。我是否正确理解它不支持相对路径? 我正在尝试将此 svg 路径转换为 UIBezierPath: // svg path m90 36c
我正在尝试制作一个球从用户画线反弹的游戏。绘制线的代码包含在下面并且可以正常工作,但是一旦球与它接触或玩家画一条新线,我将如何删除线? path = [UIBezierPath bezierPath]
我想画一条这样的路径: 这就是我写的: CGFloat radius = 50; UIBezierPath *path = [UIBezierPath bezierPath]; [path moveT
我在 View 中有一个 UIBezierPath 。我想在单击形状时显示警报,但实际发生的情况是,不仅在我单击形状时显示警报,而且当我单击 View 中的任意位置时也会显示警报。 如何更改此代码,以
我正在尝试从圆形到带圆角的正方形制作动画。据我了解,对于流畅的动画,两条路径的点数应该相等。所以我写了一个基于多条弧构建圆的函数: private func circleShape(segmentNu
对于横向和纵向模式,是否可以将元素重置到相同的%位置(距x = 0轴的距离)?如果是的话你能告诉我怎么做吗?另外,由于我是 Swift 的新手,如果您发现任何错误的代码错误,请DO通知我以便得到更好的
我正在尝试在叠加渲染器中使用 UIBezierPath 绘制一些线条。我收到错误 CGContextSetStrokeColorWithColor: invalid context 0x0 我怀疑这是
我想圆化我的右角,但只适用于左角 let path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: [UIRectCorner.
我想圆化我的右角,但只适用于左角 let path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: [UIRectCorner.
当我尝试平移路径,将其移动到原点 {0, 0} 时,生成的路径边界错误。 (或者,我的假设是错误的)。 例如该路径给出以下边界信息: let bezier = UIBezierPath(cgPath:
我是一名优秀的程序员,十分优秀!