user2428168
user2428168

Reputation: 337

Multiple CGAffineTransforms in Swift 3

In Swift 2, we could do this to get a rotation and a stretch:

let rotate = CGAffineTransformMakeRotation(1) 
let stretchAndRotate = CGAffineTransformScale(rotate, 0.8, 0.8) 
label.transform = stretchAndRotate

In Swift 3, CGAffineTransformScale has become CGAffineTransform and no longer accepts a rotation.

What is the simplest way to apply a stretch and rotation to an object now?

Thanks,

Rob

Upvotes: 8

Views: 11047

Answers (1)

Martin R
Martin R

Reputation: 540065

In Swift 3 many global C functions are mapped to member functions of the corresponding type, compare "Import as member" on swift-evolution.

In your case it would be

let rotate = CGAffineTransform(rotationAngle: 1.0)
let stretchAndRotate = rotate.scaleBy(x: 0.8, y: 0.8)

Upvotes: 31

Related Questions