iOS 用从左到右的动画取消隐藏视图
Posted
技术标签:
【中文标题】iOS 用从左到右的动画取消隐藏视图【英文标题】:iOS unhide view with left to right animation 【发布时间】:2015-11-05 09:55:06 【问题描述】:我在情节提要中添加了视图,它最初是隐藏的。 我取消隐藏按钮点击视图如下:
_myView.hidden=NO;
我想用从左到右的动画故事板取消隐藏这个视图? 我怎么能设置动画呢? 提前致谢。
【问题讨论】:
显示你尝试过的代码 这个视图从左到右 @Divyesh 试试这个链接***.com/questions/9115854/animating-hide-show 查看此链接***.com/questions/16357005/… 【参考方案1】:/===查看动画====/
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)
【讨论】:
创建一个空的 swift 文件并添加上面的代码文件,您可以将它与 Objective-c 一起使用,如常规帮助类 如果您遇到任何问题,请随时询问,我会在 Github 上添加一个项目 :)以上是关于iOS 用从左到右的动画取消隐藏视图的主要内容,如果未能解决你的问题,请参考以下文章
IOS / Objective-C / Storyboard:从左到右的自定义Segue在视图控制器之间创建黑条