我一直在查看加载屏幕的不同示例 - 有没有办法在检测到点击时插入过渡屏幕(滑动)?目前UIImage.imageNamed立即加载下一个图形 - 如何使其滑动?
def viewDidLoad
view.image = UIImage.imageNamed('welcome.png')
view.userInteractionEnabled = true
recognizer = UITapGestureRecognizer.alloc.initWithTarget(self, action:'nextScreen')
view.addGestureRecognizer(recognizer)
end
答案 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