iosswiftcgaffinetransform

CGAffineTransformConCat/ CGAffineTransformMakeScale in Swift 3


I'm trying to update a part of a function for swift 3:

  let newLabelOffset = CGFloat(direction.rawValue) * originalFrame.size.height/2

    newLabel.transform = CGAffineTransformConCat(
      CGAffineTransformMakeScale(1,0)
      CGAffineTransformMakeTranslation(0,newLabelOffset)
    )

I've heard that the new way of using CGAffineTransformConCat is concatenating(_:) but not entirely sure how to set it up based on the 2 above transforms.


Solution

  • Init transforms,

    let trans1 = CGAffineTransform(scaleX: 0, y: 0)
    let trans2 = CGAffineTransform(translationX: 0,y: 1)
    

    Concatenate,

    trans1.concatenating(trans2)