NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

How to compensate for the movement ArchorPoint

Forums > Swift

Good day. I just can’t understand how to compensate for the change ArchorPoint? I will be grateful for the clarification

https://github.com/StevenKirke/ArchorPoint_Example_BackUp/tree/master/ArchorPointExample

   

Did so

       box.layer.anchorPoint = convertPoint(points: CGPoint(x: 0, y: 1))

        animationCube()

    }

    func convertPoint(points: CGPoint) -> CGPoint {
        let ss = points
        let oldOrigin = box.frame.origin
        circleRedCenterCube.center = oldOrigin
        print(oldOrigin)
        box.layer.anchorPoint = ss
        let newOrigin = box.frame.origin
        circleGreenNew.center = newOrigin
        print(newOrigin)
        let changeOrigin = CGPoint(x: newOrigin.x - oldOrigin.x, y: newOrigin.y - oldOrigin.y)
        box.center = CGPoint(x: box.center.x - changeOrigin.x, y: box.center.y - changeOrigin.y)
        return ss
    }

   

Hacking with Swift is sponsored by Paw

SPONSORED Use Paw to build, test and describe web APIs. Paw has a lightning fast native macOS interface to compose requests, collaborate in real-time on API specs, and generate client code for your applications. You can import and export API definitions.

Discover Paw for Mac

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

Not logged in

Log in
 

Link copied to your pasteboard.