【发布时间】:2017-07-02 22:25:55
【问题描述】:
我有一个 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
【问题讨论】:
-
你的图片尺寸是多少,你设置了什么内容模式? AspectFit?方面填充?
-
谢谢,这确实帮助我弄清楚了。我有 AspectFit,但纵横比当然是错误的,因为顶部栏正在挤压它。
标签: ios swift uiviewcontroller uinavigationcontroller