开发者

Movable UIViews, like Tangram

In my iPad app开发者_开发百科lication, there is one main view. It contains various views which have different sizes and different images (tetragons, but not rectangles).

Movable UIViews, like Tangram

(source: idzr.org)

The grey lines represent the frames, the red lines represent the outline of the image.

It is a bit like Tangram, but more complicated since the tetragons are not rectangles.

The views can be moved and rotated, but the red tetragons should not touch one another, and not overlay one another. If the corners of the tetragons are known, what is the best way to implement this?


Apple has an example of how to handle this: http://developer.apple.com/library/ios/#samplecode/Touches/Introduction/Intro.html

Basically, each of your shapes will be a UIView subclass and you'll just need to respond to the proper touch events to move and rotate them accordingly. Yours will just be slightly more complicated because your shapes will have to check to make sure they're not going to overlap another shape when it moves/rotates.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜