iphone - 如何在瀑布 View 中自动设置图像宽度和高度?

标签 iphone ios user-interface

我正在像 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/

相关文章:

java - 无法正确定义处理程序方法来关闭主程序框架和对话框弹出窗口

ios - Xcode - 将字体从 iPhone 缩放到 iPad 大小

iphone - 核心数据排序并且不显示重复项

iPhone 应用程序崩溃并且没有留下 .crash 日志文件

iphone - 如何从 google api 调用获取单个目的地的多条距离路线结果?

objective-c - 如何从 UITableViewCell 推送 View

ios - 有谁知道 iOS 是否可以选择在 View 顶部有这个圆形灰色 View 的地方添加此功能?

ios - 尝试在 IOS 上的 chrome 上使用 FB.ui 时避免出现 "unsupported browser ..."的任何解决方法

Java用户界面: add simple chart

Python - 对齐 Tkinter 标签文本