我正在像 pinterest 一样构建瀑布 View 。现在我必须明确设置每个图像的宽度和高度,有没有办法让图像自动填充合适的宽度和高度?
最佳答案
根据UIImageView
Class Reference , 在 initWithImage:
This method adjusts the frame of the receiver to match the size of the specified image. It also disables user interactions for the image view by default.
如果您的图像在 UIImage
对象中,调用 initWithImage:
应该会创建一个 UIImageView
,并为您的图片提供适当大小的框架。
// Get your UIImage from somewhere
UIImage *myImage = ...
UIImageView *imageView = [[UIImageView alloc] initWithImage:myImage];
关于iphone - 如何在瀑布 View 中自动设置图像宽度和高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11166993/