I'm building an app that can add UILabel(can move with gesture) on UIView.
First, Add a label and move it to another position. Second, Add another label. Then makeConstraints have an effect on first label.
I wanna maintain first label's position How can I do?
@IBAction func touchAddText(_ sender: Any) {
logp("touchAddText")
let newLabel = UILabel()
newLabel.text = "Text"
newLabel.isUserInteractionEnabled = true
newLabel.tag = self.labelList.count + 1
newLabel.addGestureRecognizer(self.setGesture())
self.labelList.append(newLabel)
self.containerMain.addSubview(newLabel)
newLabel.snp.makeConstraints {
$0.center.equalToSuperview()
}
}