[英]How to set image width and height automatically in a waterfall view?
我正在像pinterest一樣構建瀑布視圖。 現在,我必須顯式設置每個圖像的寬度和高度,有沒有辦法讓圖像自動填充合適的寬度和高度?
根據UIImageView
類參考 ,在initWithImage:
下initWithImage:
此方法調整接收器的幀以匹配指定圖像的大小。 默認情況下,它還會禁用圖像視圖的用戶交互。
如果您的圖像位於UIImage
對象中,則調用initWithImage:
應該會為您的圖片創建一個UIImageView
並帶有適當大小的框架。
// Get your UIImage from somewhere
UIImage *myImage = ...
UIImageView *imageView = [[UIImageView alloc] initWithImage:myImage];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.