请教一个 autolayout,总是提示约束冲突
如图,我用 A 方法和 B 方法都提示冲突
前提: green view 必须有高度约束的 50
A布局中:
red 距离 super view top 10
green 距离 red view top 10
green 距离 super view bottom 20
此时提示 green 冲突了,不能同时满足 height 和 距离 super view bottom 20
B布局中:
red 距离 super view top 10
green 距离 red view top 10
purple 距离 green view top 0
purple 距离 super view bottom 20
此时还是提示冲突,怎么满足 green view 必须有高度约束呢?
相关代码
titleLabel.autoPinEdgeToSuperviewEdge(ALEdge.Top, withInset: verticalInsets)
titleLabel.autoPinEdgeToSuperviewEdge(ALEdge.Left, withInset: horizontalInsets)
titleLabel.autoPinEdgeToSuperviewEdge(ALEdge.Right, withInset: horizontalInsets)
dateLabel.autoPinEdgeToSuperviewEdge(ALEdge.Left, withInset: horizontalInsets)
dateLabel.autoPinEdge(ALEdge.Top, toEdge: ALEdge.Bottom, ofView: titleLabel, withOffset: verticalInsets / 2)
coverImage.autoPinEdge(ALEdge.Top, toEdge: ALEdge.Bottom, ofView: dateLabel, withOffset: verticalInsets)
coverImage.autoPinEdgeToSuperviewEdge(ALEdge.Left, withInset: horizontalInsets)
coverImage.autoPinEdgeToSuperviewEdge(ALEdge.Right, withInset: horizontalInsets)
coverImage.autoSetDimension(ALDimension.Height, toSize: screenWidth * 0.5597014925)
bottomGap.autoPinEdge(ALEdge.Top, toEdge: ALEdge.Bottom, ofView: coverImage)
bottomGap.autoPinEdgeToSuperviewEdge(ALEdge.Bottom, withInset: verticalInsets)
这是一个 uitableviewcell 的布局,bottom也必须要有 Pin,否则自动检测高度无效。
麥田守望者
10 years, 2 months ago