Я создаю кнопку программно, и CGAffineTransform
не работает в моем проекте при добавлении addTarget
, почему?
ИЗМЕНИТЬ:
func createButtonPuzzle(id: Int) {
for i in 1...14 {
let btnButton = UIButton(type: .roundedRect)
btnButton.frame = CGRect(x: self.view.frame.size.width / 2, y: self.view.frame.size.height / 2, width: 100, height: 100)
btnButton.backgroundColor = .blue
btnButton.setTitle("iButton", for: .normal)
btnButton.addTarget(self, action: #selector(moveButton(sender:)), for: .touchUpInside)
view.addSubview(btnButton)
}
}
func moveButton(sender: UIButton) {
if sender.tag == 1 {
if sender.transform == CGAffineTransform.identity {
UIView.animate(withDuration: 0.5, animations:
sender.transform = CGAffineTransform(translationX: 50, y: 100)
})
}
}
}
moveButton
? - person dfd   schedule 31.07.2017.tag = 1
, поэтому вы никогда не будете выполнять код внутри оператораif sender.tag == 1
. - person Alexey Tyurnin   schedule 01.08.2017