我有一个像照片共享这样的应用程序,我需要在像 GOOGLE IMAGE SEARCH 这样的平铺视图中显示图像。
照片应根据图像的大小以平铺方式排列为了更好地解释,我附上了谷歌图像搜索的示例。
和
如果您对此有任何想法,请分享您的知识。
我有一个像照片共享这样的应用程序,我需要在像 GOOGLE IMAGE SEARCH 这样的平铺视图中显示图像。
照片应根据图像的大小以平铺方式排列为了更好地解释,我附上了谷歌图像搜索的示例。
和
如果您对此有任何想法,请分享您的知识。
这是类似于您所要求的iOS库的源代码。您可以从Source Code获得有关如何完成此操作的基本概念。
使用滚动视图。
设置两个参数,分别称为 xOffset 和 yOffset 和 UIScrollview *scrollView
int yOffset = 0;
int xOffset = 0;
for (int height=0; height < [y count]; height++)
{
for (int width=0; width < [x count]; width++)
{
NSString *imageName =
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(xOffset, yOffset, imageView.frame.size.width, imageView.frame.size.height);
[scrollView addSubview:imageView];
xOffset += imageView.frame.size.width;
}
yOffset += imageView.frame.size.height;
}
[scrollView setContentSize:CGSizeMake(xOffset,yOffset)];
希望这可以帮助...