先做层级,再做位置:
另一思路,是指定视图的 zIndex
func forUI(){
// 层次关系,很重要。不好改的
view.addSubs([ playingV, tShowD, contentHan,
progressV, bottomBoard, panelG
])
if calData.isFromStd{
view.addSubs([editX_bt, progressChoosePop])
}
layout_h()
h.addSubs([rhsMostMenuBtn, downloadB])
if calData.isFromStd{
tShowD.addSubs([vertBar])
}
view.addSubs([darkCurtain, donePop,
lhsPopViewSpacing, rhsPopViewTimes, speedSelectIdxV])
v.addSubs([resultPop])
let topRhsWidget: (ConstraintMaker) -> Void = { m in
m.size.equalTo(CGSize(width: 32, height: 32))
m.trailing.equalToSuperview().offset(-16)
m.centerY.equalTo(self.h.arrow)
}
if calData.isFromStd{
vertBar.snp.makeConstraints { (m) in
m.size.equalTo(CGSize(width: 8, height: 16))
m.leading.equalToSuperview().offset(16)
m.top.equalToSuperview().offset(24)
}
editX_bt.snp.makeConstraints{ (m) in
m.leading.equalToSuperview().offset(16)
m.trailing.equalToSuperview().offset(-16)
m.top.equalTo(h.snp.bottom).offset(16)
m.height.equalTo(40)
}
tShowD.snp.makeConstraints{ (m) in
m.leading.trailing.equalToSuperview()
m.top.equalTo(editX_bt.snp.bottom)
m.bottom.equalTo(bottomBoard.snp.top)
}
rhsMostMenuBtn.snp.makeConstraints(topRhsWidget)
downloadB.snp.makeConstraints { (m) in
m.size.equalTo(CGSize(width: 32, height: 32))
m.centerY.equalTo(h.arrow)
m.trailing.equalTo(rhsMostMenuBtn.snp.leading).offset(-16)
}
}
else{
tShowD.snp.makeConstraints { (m) in
m.leading.trailing.equalToSuperview()
m.top.equalTo(h.snp.bottom)
m.bottom.equalTo(bottomBoard.snp.top)
}
downloadB.snp.makeConstraints(topRhsWidget)
}
playingV.snp.makeConstraints { (m) in
m.leading.trailing.equalToSuperview()
m.top.equalTo(h.snp.bottom)
m.bottom.equalTo(progressV.snp.top)
}
panelG.snp.makeConstraints { (m) in
m.leading.trailing.equalToSuperview()
m.height.equalTo(panelG.h)
self.constraintA.bottomPanelG = m.bottom.equalTo(progressV.snp.top)
}
bottomBoard.snp.makeConstraints { (m) in
m.leading.trailing.equalToSuperview()
m.height.equalTo(bottomBoard.heightStd)
m.bottom.equalToSuperview()
}
progressV.snp.makeConstraints { (m) in
m.leading.trailing.equalToSuperview()
m.height.equalTo(progressV.h)
m.bottom.equalTo(bottomBoard.snp.top)
}
resultPop.snp.makeConstraints { (m) in
m.size.equalTo(resultPop.size)
m.center.equalToSuperview()
}
donePop.snp.makeConstraints { (m) in
m.size.equalTo(donePop.size)
m.center.equalToSuperview()
}
darkCurtain.snp.makeConstraints { (m) in
m.edges.equalToSuperview()
}
if calData.isFromStd{
progressChoosePop.snp.makeConstraints { (m) in
m.leading.trailing.equalToSuperview()
constraintA.bottomChoosePop = m.bottom.equalTo(h)
constraintA.heightChangeChoosePop = m.height.equalTo(self.progressChoosePop.popH)
}
}
lhsPopViewSpacing.snp.makeConstraints { (m) in
m.leading.trailing.equalToSuperview()
m.height.equalTo(150 + UI.std.bottomOffsetY)
m.bottom.equalToSuperview()
}
rhsPopViewTimes.snp.makeConstraints { (m) in
m.leading.trailing.equalToSuperview()
m.height.equalTo(160 + UI.std.bottomOffsetY)
m.bottom.equalToSuperview()
}
speedSelectIdxV.snp.makeConstraints { (m) in
m.leading.trailing.equalToSuperview()
m.height.equalTo(150 + UI.std.bottomOffsetY)
m.bottom.equalToSuperview()
}
view.layoutIfNeeded()
}
不会出现奇怪的动画
view.layoutIfNeeded()
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。