iOS取消隐藏视图,从左到右动画

时间:2015-11-05 09:55:07

标签: ios objective-c animation uiview storyboard

我在故事板中添加了最初隐藏的视图。 我按下按钮取消隐藏视图,如下所示:

_myView.hidden=NO;

我想用左到右动画故事板取消隐藏此视图? 我怎么能设置这个动画? 提前谢谢。

1 个答案:

答案 0 :(得分:0)

/ ===查看动画==== /

class func viewSlideInFromRightToLeft(views: UIView) {
        var transition: CATransition? = nil
        transition = CATransition()
        transition!.duration = 0.5
        transition!.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
        transition!.type = kCATransitionPush
        transition!.subtype = kCATransitionFromRight
        transition!.delegate = self
        views.layer.addAnimation(transition!, forKey: nil)
    }
   class func viewSlideInFromLeftToRight(views: UIView) {
        var transition: CATransition? = nil
        transition = CATransition()
        transition!.duration = 0.5
        transition!.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
        transition!.type = kCATransitionPush
        transition!.subtype = kCATransitionFromLeft
        transition!.delegate = self
        views.layer.addAnimation(transition!, forKey: nil)
    }
   class func viewSlideInFromTopToBottom(views: UIView) {
        var transition: CATransition? = nil
        transition = CATransition()
        transition!.duration = 0.5
        transition!.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
        transition!.type = kCATransitionPush
        transition!.subtype = kCATransitionFromTop
        transition!.delegate = self
        views.layer.addAnimation(transition!, forKey: nil)
    }
   class func viewSlideInFromBottomToTop(views: UIView) {
        var transition: CATransition? = nil
        transition = CATransition()
        transition!.duration = 0.5
        transition!.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
        transition!.type = kCATransitionPush
        transition!.subtype = kCATransitionFromBottom
        transition!.delegate = self
        views.layer.addAnimation(transition!, forKey: nil)
    }



 viewName.hidden=false 
self.viewSlideInFromLeftToRight(viewName)