Ios 如何在Xcode上以编程方式生成一行图像
我正在尝试制作一款iOS游戏,它要求玩家尽可能多地捕捉硬币。我知道以编程方式显示硬币,但是如何轻松地制作一行硬币呢。类似于游戏线跑步者,跑步者必须接住硬币或喷气背包 我在想类似的事情 游戏是风景画Ios 如何在Xcode上以编程方式生成一行图像,ios,objective-c,Ios,Objective C,我正在尝试制作一款iOS游戏,它要求玩家尽可能多地捕捉硬币。我知道以编程方式显示硬币,但是如何轻松地制作一行硬币呢。类似于游戏线跑步者,跑步者必须接住硬币或喷气背包 我在想类似的事情 游戏是风景画 randomPlace = arc3random()%315; coinImage.center = CGPointMake(coinImage.center.x - 1, randomPlace); coinImage1.center = CGPointMake(coinImage1.center.
randomPlace = arc3random()%315;
coinImage.center = CGPointMake(coinImage.center.x - 1, randomPlace);
coinImage1.center = CGPointMake(coinImage1.center.x - 1, randomPlace);
我甚至不知道我是否在正确的轨道上,但有人能帮我吗?谢谢大家! 您可以使用类似的方法在水平线上创建5个图像:
//Generate your variables
float width = 15, height = 15;
float originX = 20, originY = 50, spacing = 5;
//Create 5 image views
for (int i = 0; i < 5; i++) {
UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(originX + ((spacing + width) * i), originY, width, height)];
[imgV setImage:[UIImage imageNamed:@"YourImage.png"]];
[self.view addSubview:imgV];
}
//生成您的变量
浮动宽度=15,高度=15;
浮点数原点=20,原点=50,间距=5;
//创建5个图像视图
对于(int i=0;i<5;i++){
UIImageView*imgV=[[UIImageView alloc]initWithFrame:CGRectMake(原点+((间距+宽度)*i),原点,宽度,高度)];
[imgV setImage:[UIImage ImageName:@“YourImage.png”];
[self.view addSubview:imgV];
}
这将产生如下结果:
有没有办法用UIImageView做到这一点?答案是使用
UIImageView
s,你的问题是什么?