Skip to content

Instantly share code, notes, and snippets.

@trilliwon
Created February 22, 2019 09:30
Show Gist options
  • Select an option

  • Save trilliwon/de794949813b0a88dcefecf2f106608f to your computer and use it in GitHub Desktop.

Select an option

Save trilliwon/de794949813b0a88dcefecf2f106608f to your computer and use it in GitHub Desktop.
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