2012-06-11 26 views
0

我一直在尋找不同的加載屏幕的例子 - 有沒有辦法在探測到水龍頭時插入轉換屏幕(滑動)?目前UIImage.imageNamed立即加載下一個圖形 - 如何使它滑動?如何在RubyMotion中進行滑動切換?

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

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

回答

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