Multiple CGAffineTransforms in Swift 3

10,985

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)
Share:
10,985
user2428168
Author by

user2428168

Updated on July 27, 2022

Comments

  • user2428168
    user2428168 almost 2 years

    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