簡體   English   中英

如何讓我的圖像完全適合UIView

[英]How can I make my image fit in completely in a UIView

我正在應用的圖像在IPhone7加模擬器和IPhone 5模擬器中看起來很好,它不像我想要的。 我附上了兩張圖片。 請幫我。

在此輸入圖像描述

第二張圖片:

在此輸入圖像描述

約束:

在此輸入圖像描述

像這樣我想要兩個圖像一個在另一個上面

跟着這些步驟:

  1. 在故事板中,使用UIview的自動布局,如下所示:從左側,頂部,高度,寬度添加約束
  2. 它適用於所有屏幕

使用Propotional Constraints而不是給出修復widh,heigth Constraints。

假設您的View有250寬度和100高度,您正在設計375寬xib的單元格。

給予約束的步驟

1 :- Leading Constraints  same as you described in your image.
2 :- Center Vertical Constraints same as you described in your image.
3 :- Give aspect Ratio to your View.
4 :- Give equal width Constarint of Your View with Super View.

乘數計算: - > 250/375 = 0.6666666667

編輯最后一個Constarint,其名稱應如下所示: Propotional Width ,編輯該Constarint並將multipier設為0.6666666667

如果你用委托方法設置了適當的單元格高度,它應該幾乎可以工作。

我認為你在設計時在故事板中使用7加屏幕分辨率。 在約束加載之前應用拐角半徑。

超級調用后,在layoutSubviews方法中應用您的角半徑。

為該UIView添加以下約束。

1. Leading space to its superview 2. Trailing space to nearest label 3. Add the constraint Vertically in container 4. Set Width constraint 5. Set height constraint.

會很完美。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM