这听起来像你在正确的轨道上。我会尽力满足您的期望,一个在时间点:
的意见,屏幕可以是自定义UIView子类或UIImageViews的。您可能想要考虑您将来要添加的其他功能。 UIView方法提供了最大的灵活性,并且还允许您通过手动绘制汽车图像来处理旋转。为此,创建一个UIView的子类,给它一个图像属性和一个旋转属性,然后重写“drawRect:(CGRect)矩形”函数来绘制图像。
在视图控制器中放置汽车阵列听起来不错。
在Interface Builder NIB文件中存储初始布局通常是最好的选择。它允许您在将来轻松更改界面,并删除创建和定位屏幕所需的大量样板代码。
这就是说,无法将一堆视图绑定到单个阵列插座。在这种特殊情况下,我将实现视图控制器的“viewDidLoad”函数来创建多个汽车。你在正确的轨道上!
无法在Interface Builder中设置旋转,因为它不是流行的选项。您可以使用CAAnimation变换实现旋转以设置旋转属性,然后以一定角度手动绘制图像。
希望帮助!
编辑:这里是一些示例代码来绘制一个角度的图像。它使用Quartz(也称为Core Graphics) - 因此Apple文档中提供了更多信息
- (void)drawRect:(CGRect)r
{
// get the drawing context that is currently bound
CGContextRef c = UIGraphicsGetCurrentContext();
// save it's "graphics state" so that our rotation of the coordinate space is undoable.
CGContextSaveGState(c);
// rotate the coordinate space by 90º (in radians). In Quartz, images are
// always drawn "up," but using CTM transforms, you can change what "up" is!
// Can also use TranslateCTM and ScaleCTM to manipulate other properties of coordinate space.
CGContextRotateCTM(c, M_PI/2);
// draw an image to fill our entire view. Note that if you want the image to be semi-transparent,
// the view must have opaque = NO and backgroundColor = [UIColor clearColor]!
CGContextDrawImage(c, self.bounds, [[UIImage imageNamed:@"image_file.png"] CGImage]);
// restore the graphics state. We could just rotate by -M_PI/2, but for complex transformations
// this is very handy.
CGContextRestoreGState(c);
}
这是非常有帮助的。你能指出更多的文档或例如“手动”绘制90°角的图像吗?我不熟悉仿射变换。那是我想要的吗? – Meltemi 2009-06-30 20:16:36