ios - UIView appereance 从下到上,反之亦然(核心动画)

标签 ios xamarin uiview xamarin.ios core-animation

我的目标是通过 Core Animation 理解和实现功能。
我认为这并不难,但不幸的是我不知道 swift/Obj C 并且很难理解 native 示例。


可视化实现

那么我到底想做什么(如图所示的几个步骤):
1. Source
2. enter image description here
3. enter image description here
4. enter image description here

和隐藏 View 的相同步骤(反之亦然,从上到下)直到:

enter image description here

此外,我想让这个 UIView 更通用,我的意思是将这个 UIView 放在我的 StoryBoard 上,并对 AutoLayout 施加约束(以支持不同的设备屏幕) .

有什么想法吗?谢谢!

最佳答案

You can use like this Extension

extension UIView{
    func animShow(){
        UIView.animate(withDuration: 2, delay: 0, options: [.curveEaseIn],
                       animations: {
                        self.center.y -= self.bounds.height
                        self.layoutIfNeeded()
        }, completion: nil)
        self.isHidden = false
    }
    func animHide(){
        UIView.animate(withDuration: 2, delay: 0, options: [.curveLinear],
                       animations: {
                        self.center.y += self.bounds.height
                        self.layoutIfNeeded()

        },  completion: {(_ completed: Bool) -> Void in
        self.isHidden = true
            })
    }
}

关于ios - UIView appereance 从下到上,反之亦然(核心动画),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42326892/

相关文章:

ios - 在 swift 中以编程方式添加 "Vertical Spacing"

ios - UITextField ResignFirstResponder 在 UIScrollView 上崩溃

xamarin - 将字符串数据从 Android MainActivity 传递到 PCL TabbedPage xamarin.form

ios - Xcode git 显示多个存储库

ios - swift 3.1 : Crash when custom error is converted to NSError to access its domain property

c# - Xamarin Google Cloud Messaging GcmClient.CheckDevice(this) 导致运行时错误

c# - 加载只出现在代码执行结束时

iphone - 动画 NSLayoutConstraints 更改(以及对更改的对象有约束的对象)

ios - 在 iOS 中从 map 生成图像

ios - 重叠不同颜色和 Alpha 的 UIView