我想制作一个由其他 UIImage 制成的 UIImage,大约 10x10 个其他 UIImage,就像一个网格。有什么办法可以做到这一点?
编辑 1:这是我目前基于 lnafziger 链接的代码:
- (void)displayFullMap
{
NSInteger x, y;
UIGraphicsBeginImageContext(CGSizeMake(xMapLength * 64, yMapLength * 64));
CGRect rect = CGRectMake(0, 0, xMapLength * 64, yMapLength * 64);
UIImage *imageToAdd = [[UIImage alloc] init];
for (int i = 0; i < xMapLength; i++) {
for (int j = 0; j < yMapLength; j++) {
imageToAdd = some64x64image;
[imageToAdd drawInRect:rect];
rect.origin.x += 64;
}
rect.origin.x = 0;
rect.origin.y += 64;
}
UIImage *fullMapImage = [[UIImage alloc] init];
fullMapImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageView *fullMapImageView = [[UIImageView alloc] init];
[fullMapImageView setFrame:CGRectMake(0, 0, 360, 480)];
[fullMapImageView setImage:fullMapImage];
[self.view addSubview:fullMapImageView];
UIGraphicsEndImageContext();
}
但是,没有显示图像。我究竟做错了什么?