![](/img/trans.png)
[英]SwiftUI How to determine whether image was taken in landscape or portrait?
[英]How to check whether the downloaded image is Portrait or Landscape in ios?
在我的項目中,我必須使用從URL獲取的圖像填充UITableViewCell
。 很好,我將URL轉換為Image,但是出現了問題,如何檢查下載的圖像是Portrait還是Landscape?
只需檢查其大小即可:
UIImage* myImage = ...;
if (myImage.size.width > myImage.size.height)
{
//landscape
}
else
{
//portrait
}
請按照以下步驟操作:
如果(寬度/高度> 1)
// you can consider it as Landscape Image.
其他
// you can consider it as Portrait Image.
如果您需要進一步說明,請告訴我。
通過這些條件,只需檢查圖像的寬度和高度。
UIImage* yourImg = @"imgName";
if (yourImg.size.width > yourImg.size.height)
{
//yourImg is Landscape
}
else
{
//yourImg is Portrait
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.