Created
February 22, 2019 09:30
-
-
Save trilliwon/de794949813b0a88dcefecf2f106608f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let min = CGFloat(-30) | |
| let max = CGFloat(30) | |
| let xMotion = UIInterpolatingMotionEffect(keyPath: "layer.transform.translation.x", type: .TiltAlongHorizontalAxis) | |
| xMotion.minimumRelativeValue = min | |
| xMotion.maximumRelativeValue = max | |
| let yMotion = UIInterpolatingMotionEffect(keyPath: "layer.transform.translation.y", type: .TiltAlongVerticalAxis) | |
| yMotion.minimumRelativeValue = min | |
| yMotion.maximumRelativeValue = max | |
| let motionEffectGroup = UIMotionEffectGroup() | |
| motionEffectGroup.motionEffects = [xMotion,yMotion] | |
| imageView.addMotionEffect(motionEffectGroup) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment