Skip to content

Instantly share code, notes, and snippets.

@cactis
Created April 19, 2014 04:46
Show Gist options
  • Save cactis/11074398 to your computer and use it in GitHub Desktop.
Save cactis/11074398 to your computer and use it in GitHub Desktop.
How to do a sliding transition in RubyMotion?
def viewDidLoad
view.image = UIImage.imageNamed('welcome.png')
view.userInteractionEnabled = true
recognizer = UITapGestureRecognizer.alloc.initWithTarget(self, action:'nextScreen')
view.addGestureRecognizer(recognizer)
end
def nextScreen
animation = CATransition.animation
animation.duration = 0.5
animation.type = KCATransitionMoveIn
animation.subtype = KCATransitionFromRight
view.layer.addAnimation(animation, forKey:'imageTransition')
view.image = UIImage.imageNamed('pic2.png')
end
Source: http://stackoverflow.com/a/5057691/424300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment