我有一个内部有几个元素的scrollview。我必须将底部标签设置为粘贴在视图的底部,无论如何但不应与屏幕较小时发生的视图重叠。
如何在Snapkit中实现这一目标?
答案 0 :(得分:1)
someScrollView.translatesAutoresizingMaskIntoConstraints = false
let stickyLabel = UILabel()
stickyLabel.backgroundColor = UIColor.red
stickyLabel.translatesAutoresizingMaskIntoConstraints = false
stickyLabel.text = "some sticky bottom label"
self.view.addSubview(stickyLabel)
someScrollView.snp.makeConstraints { (make) -> Void in
make.top.leading.trailing.equalToSuperview()
}
stickyLabel.snp.makeConstraints { (make) -> Void in
make.top.equalTo(someScrollView.snp.bottom).offset(4)
make.leading.equalToSuperview().offset(4)
make.bottom.trailing.equalToSuperview().offset(-4)
}
会给出类似的东西: