Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的应用程序中,我正在开发一种瓷砖系统。我打算让 UIImageViews “捕捉”到特定位置,而不是手动制作我的瓷砖。
这是我的问题:
如何将我的新位置四舍五入(在我的情况下)16?
与您对单个float值的处理方式相同。
float
CGPoint snap(CGPoint p) { return CGPointMake(roundf(p.x / 16) * 16, roundf(p.y / 16) * 16); }