答案 0 :(得分:0)
您需要为按钮及其超级视图设置正确的约束。另外,按钮的大小也很重要。
在您的情况下,代码非常简单,可以说我是使用Snapkit自动布局工具编写的:
attendeeLabel.snp.makeConstraints { make in
make.top.centerY.bottom.equalToSuperview()
make.left.equalToSuperview().offset(15)
}
cancelButton.snp.makeConstraints { make in
make.top.equalTo(attendeeLabel.snp.top).offset(10)
make.left.equalTo(attendeeLabel.snp.right).offset(5)
make.right.lessThanOrEqualToSuperview() // <-- this will keep the button on the right side of the label, but will not exceed the superview
make.width.height.equalTo(22) // <-- this is the size of the close button
}
答案 1 :(得分:0)