简体   繁体   English

无法为 UIView 设置约束

[英]Unable to set constraint for UIView

I am new to app making and trying to make a single view app.我是应用程序制作的新手,正在尝试制作单视图应用程序。 There is a button at the bottom of the screen on click of which I want to expand a UIView which will have other buttons as well to navigate further.点击屏幕底部有一个按钮,我想展开一个UIView ,它还有其他按钮可以进一步导航。

iPhone 11 Pro Max simulator image: iPhone 11 Pro Max 模拟器图片:

iPhone 11 Pro Max 模拟器图片

However, while checking this layout for a smaller device, the circle is getting clipped as shown below from the sides:但是,在为较小的设备检查此布局时,圆形被从侧面剪裁,如下所示:

iPhone 8 simulator image: iPhone 8 模拟器图片:

iPhone 8 模拟器图片

The dimensions for the UIView is width = 414 and height = 400 (to make it look right on iPhone 11 Pro Max). UIView的尺寸为宽度 = 414 和高度 = 400(使其在 iPhone 11 Pro Max 上看起来正确)。

Autoresizing and setting constraint doesn't really help.自动调整大小和设置约束并没有真正帮助。

Appreciate any and every kind of input.欣赏任何和每一种输入。

Thanks in advance.提前致谢。

  1. Initially, set height constraint to 0 of UIView you want to expand.最初,将要扩展的 UIView 的高度约束设置为 0。
  2. Once you click the bottom button, change UIView height constraint to whatever you want.单击底部按钮后,将 UIView 高度约束更改为您想要的任何内容。

To set height constraint value-设置高度约束值-

  1. Create outlet of height constraint of UIView which you want to expand.创建要扩展的 UIView 的高度约束出口。
  2. set yourViewHeightConstraint.constant = 0 or yourViewHeightConstraint.constant = 400设置 yourViewHeightConstraint.constant = 0 或 yourViewHeightConstraint.constant = 400

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM