gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 13:33:47 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com