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.
私のアプリケーションでは、一種のタイルシステムを開発しています。タイルを手動で実行する代わりに、特定の場所に「スナップ」するUIImageViewを使用することを計画しています。
これが私の質問です:
新しい場所を(私の場合は)16倍に丸めるにはどうすればよいですか?
float個々の値を使用する場合と同じです。
float
CGPoint snap(CGPoint p) { return CGPointMake(roundf(p.x / 16) * 16, roundf(p.y / 16) * 16); }