0

I'm changing anchor point by methods in this topic: Changing my CALayer's anchorPoint moves the view but it's not working for me

What I see

The view is misplaced

my view bad placed

What I Expect

The grey rectangle must expand from 1.0 in x and 0.0 in y without misplacement

My code:

private func setAnchorPoint(anchorPoint: CGPoint, view: UIView) {
       let oldOrigin = view.frame.origin
       view.layer.anchorPoint = anchorPoint
       let newOrigin = view.frame.origin
       let translation = CGPoint(x: newOrigin.x - oldOrigin.x, y: newOrigin.y - oldOrigin.y)
       view.center = CGPoint(x: view.center.x - translation.x, y: view.center.y - translation.y)
    }

setAnchorPoint(anchorPoint: CGPoint(x: 1.0, y: 0.0), view: self.actionLayer)

What I've tried

Recording in a variable the frame before changing the anchor point and setting again after, same for layer position or view center. Not working.

0 Answers0