简体   繁体   English

如何实现 Wunderlist iOS 应用程序中使用的这种类型的视图?

[英]How can I achieve this type of view used in Wunderlist iOS app?

How can I create the types of view that slide up from the bottom of the screen as pictured below?如何创建从屏幕底部向上滑动的视图类型,如下图所示? Is this a built-in view type or something custom?这是内置的视图类型还是自定义的?

The screen shots are from Wunderlist and The Hit List iOS apps respectively.屏幕截图分别来自WunderlistThe Hit List iOS 应用程序。

Just had a look at The Hit List there.刚刚在那里查看了命中列表 Seems like they're just animating a view up from the bottom.似乎他们只是从底部动画视图。

I'd go about this by creating a UIView , let's call it slidingView .我会通过创建一个UIView这个问题,我们称之为slidingView You can do it in your existing storyboard or create a new .xib file for it.您可以在现有故事板中执行此操作,也可以为其创建新的 .xib 文件。 Then, when you call your viewDidLoad for the view controller that this slidingView will be contained in, move the slidingView view off screen and animate it in whenever you want.然后,当您为包含此slidingView视图的视图控制器调用viewDidLoad时,将slidingView视图视图移出屏幕并在需要时slidingView设置动画。

Example:例子:

import UIKit

class ViewController: UIViewController {

    private struct Constants {

        static let animationDuration: TimeInterval = 0.3
        static let marginFromTop: CGFloat = 32.0

    }

    @IBOutlet private weak var slidingView: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()

        moveSlidingViewOffScreen()
    }

    // MARK: - Actions

    @IBAction func buttonTap(_ sender: UIButton) {
        UIView.animate(withDuration: Constants.animationDuration) {
            self.slidingView.frame.origin.y = Constants.marginFromTop
        }
    }

    // MARK: - Private functions

    private func setupSlidingViewOffScreen() {
        slidingView.frame.origin.y = view.frame.height
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM