Last active
August 29, 2015 14:15
-
-
Save jibla/c41b63fd4236bb083103 to your computer and use it in GitHub Desktop.
Parallax effect done with few lines in Swift
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
| // in your viewDidLoad() func. | |
| let min = -50.0 | |
| let max = 50.0 | |
| var leftRight = UIInterpolatingMotionEffect(keyPath: "center.x", type: .TiltAlongHorizontalAxis) | |
| leftRight.minimumRelativeValue = min | |
| leftRight.maximumRelativeValue = max | |
| var upDown = UIInterpolatingMotionEffect(keyPath: "center.y", type: .TiltAlongVerticalAxis) | |
| upDown.minimumRelativeValue = min | |
| upDown.maximumRelativeValue = max | |
| yourImageView.addMotionEffect(leftRight) | |
| yourImageView.addMotionEffect(upDown) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment