尝试用uarmageviews的nsarray创建一个for循环,但似乎无法让cgrectmake工作。
Location = CGRectMake(10, 10, 97, 110);
NSArray *cardImages = [[NSArray alloc]initWithObjects:car1,car2,card3,car4,car5,car6,car7,car8,car9,car10,car11, nil];
for (UIImageView *image in cardImages) {
image.frame = Location;
image.image = [UIImage imageNamed:@"ace.png"];
}
答案 0 :(得分:0)
在您当前的代码中,您要为所有UIImageView
设置相同的框架。
尝试每次迭代更改帧原点:
NSArray *cardImages = @[ card1, card2, card3, card4, card5, card6, card7, card8, card9, card10,card11 ];
for (int i = 0; i < [cardImages count]; i++) {
UIImageView *image = cardImages[i];
// Each iteration new frame will have bigger x position (0, 10, 20...)
image.frame = CGRectMake(10 * i, 10, 97, 110);
image.image = [UIImage imageNamed:@"ace.png"];
}