Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenating transform animations in Swift 3?? What is wrong?

So I am trying to concatenate two transform animations in swift 3. One is scale which will scale, and one is translate which will translate. I am trying to combine these two animations. I have an outlet named ourView which is a UIView. From my understanding I am doing everything right but it gives me this error

Value of tuple type ‘()’ has no member ‘concatenating’

Here is the code

UIView.animate(withDuration: 0.5, animations: {
    let scale = self.ourView.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)
    let translate = self.ourView.transform = CGAffineTransform(translationX: 0, y: 50)
    self.ourView.transform = scale.concatenating(translate)
})

What am I doing wrong? Does anybody have any ideas?

like image 321
John Hodge Avatar asked Jan 17 '17 15:01

John Hodge


1 Answers

You are assigning a scale transform to ourView's transform, then assigning that assignment to the scale variable. Since that assignment is a statement which doesn't take any arguments and doesn't return anything, the type of scale is (). Remove the self.ourView.transform stuff and you will be good to go.

let scale = CGAffineTransform(scaleX: 1.5, y: 1.5)
let translate = CGAffineTransform(translationX: 0, y: 50)
self.ourView.transform = scale.concatenating(translate)
like image 147
keithbhunter Avatar answered Oct 25 '22 17:10

keithbhunter