NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

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 Fernando Olivares

SPONSORED Would you describe yourself as knowledgeable, but struggling when you have to come up with your own code? Fernando Olivares has a new book containing iOS rules you can immediately apply to your coding habits to see dramatic improvements, while also teaching applied programming fundamentals seen in refactored code from published apps.

Try the book!

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.