1

更多 iPhone 的东西......有谁知道我可以如何修剪这段代码。所以我不必写每一个图像。

非常感谢

bMon01.animationImages = [NSArray arrayWithObjects: 
                    [UIImage imageNamed:@"mon01_0001.png"],
                    [UIImage imageNamed:@"mon01_0002.png"],
                    [UIImage imageNamed:@"mon01_0003.png"],
                    [UIImage imageNamed:@"mon01_0004.png"],
                    [UIImage imageNamed:@"mon01_0005.png"],
                    [UIImage imageNamed:@"mon01_0006.png"],
                    [UIImage imageNamed:@"mon01_0007.png"],
                    [UIImage imageNamed:@"mon01_0008.png"],
                    [UIImage imageNamed:@"mon01_0009.png"],
                    [UIImage imageNamed:@"mon01_0010.png"],
                    [UIImage imageNamed:@"mon01_0011.png"],
                    [UIImage imageNamed:@"mon01_0012.png"],
                    [UIImage imageNamed:@"mon01_0013.png"],
                    [UIImage imageNamed:@"mon01_0014.png"],
                    [UIImage imageNamed:@"mon01_0015.png"],
                    [UIImage imageNamed:@"mon01_0016.png"],
                    [UIImage imageNamed:@"mon01_0017.png"],
                    [UIImage imageNamed:@"mon01_0018.png"],
                    [UIImage imageNamed:@"mon01_0019.png"],
                    [UIImage imageNamed:@"mon01_0020.png"],
                    [UIImage imageNamed:@"mon01_0021.png"],
                    [UIImage imageNamed:@"mon01_0022.png"],
                    [UIImage imageNamed:@"mon01_0023.png"],
                    [UIImage imageNamed:@"mon01_0024.png"],
                    [UIImage imageNamed:@"mon01_0025.png"], nil];
4

1 回答 1

8

这是否有帮助:

NSMutableArray *array = [NSMutableArray array];
for (int i = 1; i <= 25; i++) 
  [array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"mon01_%04d.png",i]]];

bMon01.animationImages = array;
于 2009-06-30T09:45:02.877 回答