如何在 SnapKit 中按比例设置边缘偏移与超级视图高度的大小
how to set edge offset proportionally to size of superview height in SnapKit
这是我试图用 SnapKit 实现的目标,但由于明显的原因它无法编译。
contentView.snp.makeConstraints { (make) in
make.top.equalTo(scrollView).offset(scrollView.snp.height * 0.2) //ERROR - Binary operator cannot be applied to type ConstraintItem and Double
}
我会做这样的事情:
contentView.snp.makeConstraints { make in
make.height.equalToSuperview().dividedBy(2)
make.left.right.bottom.equalToSuperview()
}
这是我试图用 SnapKit 实现的目标,但由于明显的原因它无法编译。
contentView.snp.makeConstraints { (make) in
make.top.equalTo(scrollView).offset(scrollView.snp.height * 0.2) //ERROR - Binary operator cannot be applied to type ConstraintItem and Double
}
我会做这样的事情:
contentView.snp.makeConstraints { make in
make.height.equalToSuperview().dividedBy(2)
make.left.right.bottom.equalToSuperview()
}