0

高校と大学で 8 つの数学コースを読んだ後でも、私はまだこれを理解できません。

iPhone ゲームでは、多数の画像がグリッド (1 行の高さ) に配置されます。すべての画像は同じサイズです。それらを配置、中央揃え、スケーリングする関数をどのように記述すればよいですか?

例:

If there's only one image:  [        [IMAGE]         ]   - Middle of screen
Two images:                 [   [IMAGE]  [IMAGE]     ]
Three images:               [  [IMAGE][IMAGE][IMAGE  ]
etc...

各画像の幅は 100 ピクセルで、左右に 10 ピクセルのインセットが必要です。

画像が 3 つ以上ある場合は、すべての画像を縮小して画面の幅に収まるようにする必要があります (インセットで 300px)。

ありがとう

4

2 に答える 2

2

iOS 6 以降を使用している場合は、UICollectionViewの使用を検討することをお勧めします ( YouTube ビデオ チュートリアルも見つかる可能性があります)。私自身はまだ使用していませんが、このシナリオのために特別に作成されたものであると理解しています。

于 2013-02-18T19:17:12.427 に答える
1

Sounds like to me your formula should be something like: Available space = Screen width - (2 * inset)

Then to figure out how much to size the picture based on the available space you just calculated would be: individual pic width = available space / number of pictures

I am not sure if the is what you are looking for, if not please get a little more specific.

于 2013-02-18T17:54:38.760 に答える