let scroll = UIScrollView().then {
$0.backgroundColor = .red
}
view.addSubview(scroll)
scroll.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
let container = UIView().then {
$0.backgroundColor = .orange
}
scroll.addSubview(container)
container.snp.makeConstraints { make in
make.edges.equalToSuperview()
make.width.equalToSuperview()
}
let subview1 = UIView()
container.addSubview(subview1)
subview1.snp.makeConstraints { make in
make.leading.equalToSuperview().offset(20)
make.trailing.equalToSuperview().offset(-20)
make.top.equalToSuperview()
make.height.equalTo(120)
// 这行代码 不能少
make.bottom.equalToSuperview().offset(-20)
}
网友评论