[英]iOS how to get rid of extra view padding?
我有一個UINavigationController,其中有一個ViewController,它的視圖有一個背景圖像。 當我在視圖上設置這些約束時,我希望它會延伸到邊緣,但似乎會出現在左右視圖布局指南中。 這給我留下了我不想要的額外填充。 注意:我不使用情節提要板,並且設置了translatesAutoresizingMaskIntoConstraints = false
以防您認為這可能引起問題。 任何與此問題的幫助將不勝感激。
view.addSubview(backgroundImage)
backgroundImage.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
backgroundImage.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
backgroundImage.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
backgroundImage.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
您需要確保在UIImageView
上設置了正確的contentMode
; .scaleAspectFill
將確保填滿整個圖像視圖,但是由於保持正確的縱橫比而需要進行裁剪,您可能會丟失一些圖像。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.