[英]UIButton height constraint swift not working
So I have this UIButton with constraints in a storyboard that looks like this.... with constraints to safe areas as well as a height/width constraint. 因此,我的UIButton在故事板中具有如下约束:...具有安全区域约束以及高度/宽度约束。 the height constraint is set to 30 高度限制设置为30
but the output looks like... (deff not 30 height and regardless of what I set as the height constraint it looks like the following) also the buttons other than Daily are not shown because they have no constraints yet! 但是输出看起来像...(deff不是30 height,无论我设置为什么高度约束,它看起来都如下图所示),因为没有约束,所以没有显示Daily以外的按钮!
here are the constraints 这是约束
2019-03-04 01:43:35.157418-0500 Daily[831:112538] [LayoutConstraints] Unable to simultaneously satisfy constraints. 2019-03-04 01:43:35.157418-0500 Daily [831:112538] [LayoutConstraints]无法同时满足约束。 Probably at least one of the constraints in the following list is one you don't want. 以下列表中至少有一个约束是您不想要的约束。 Try this: 尝试这个:
(1) look at each constraint and try to figure out which you don't expect; (1)查看每个约束,并尝试找出不期望的约束;
(2) find the code that added the unwanted constraint or constraints and fix it (2)查找添加了一个或多个不必要约束的代码并进行修复
In this case, height and bottom constraint will conflict, I think you have set top, bottom, and height constraint property of UIbutton
, So if you want fixed height 15 then remove the bottom constraint. 在这种情况下,高度和底部约束将发生冲突,我认为您已经设置了UIbutton
top,bottom和height约束属性,因此,如果您希望将高度固定为15,则可以删除底部约束。 and if you don't want fixed hight then keep as it is a bottom constraint and remove height constraint of UIbutton
. 如果不想固定高度,则将其保留为底部约束,并移除UIbutton
高度约束。
Don't use unnecessary constraints as you were set both width and leading, trailing. 在设置宽度和前导,尾随时不要使用不必要的约束。 You can check this by updating constraints as attached image. 您可以通过将约束更新为附加图像来进行检查。
Feel free to ask me if any problem 随时问我是否有问题
*Remember, this is a sample button to guide you. *请记住,这是一个指导您的示例按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.