如何在RubyMotion中进行滑动转换?

时间:2012-06-11 11:28:27

标签: ios5 rubymotion

我一直在查看加载屏幕的不同示例 - 有没有办法在检测到点击时插入过渡屏幕(滑动)?目前UIImage.imageNamed立即加载下一个图形 - 如何使其滑动?

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

  view.userInteractionEnabled = true
  recognizer = UITapGestureRecognizer.alloc.initWithTarget(self, action:'nextScreen')
  view.addGestureRecognizer(recognizer)
end

1 个答案:

答案 0 :(得分:2)

这是一个nextScreen方法,可以做你想要的。通过动画设置,view.image = ...行将从右侧滑动图像。

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

来源:https://stackoverflow.com/a/5057691/424300