0

I've been looking at the different examples of loading a screen - is there a way to insert a transition screen (sliding) when the a tap is detected? Currently UIImage.imageNamed loads up the next graphic instantly - how to make it slide?

def viewDidLoad
  view.image = UIImage.imageNamed('welcome.png')

  view.userInteractionEnabled = true
  recognizer = UITapGestureRecognizer.alloc.initWithTarget(self, action:'nextScreen')
  view.addGestureRecognizer(recognizer)
end
Gavin Miller
  • 43,168
  • 21
  • 122
  • 188
RedNax
  • 1,507
  • 1
  • 10
  • 20

1 Answers1

2

Here is a nextScreen method that should do what you want. With the animation setup, the view.image = ... line will slide the image in from the right.

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: https://stackoverflow.com/a/5057691/424300

Community
  • 1
  • 1
Dylan Markow
  • 123,080
  • 26
  • 284
  • 201