圆形CGPoint位置

时间:2010-11-07 19:39:06

标签: iphone cgpoint

在我的应用程序中,我正在开发一种平铺系统。而不是手动执行我的图块,我计划让UIImageViews“捕捉”到特定位置。

这是我的问题:

如何将我的新位置四舍五入(在我的情况下)16?

1 个答案:

答案 0 :(得分:4)

与您对个别float值的处理方式相同。

CGPoint snap(CGPoint p) {
  return CGPointMake(roundf(p.x / 16) * 16,
                     roundf(p.y / 16) * 16);
}
相关问题