如何像 Spotify 的音乐播放器在点击歌曲时那样通过触摸垂直地为对象设置动画,

How to animate an object vertically with touch like Spotify's music player does when tapping the song,

我正在使用 Xcode,当我在屏幕底部的 imageView 上 tap/drag 时,我希望将其调出并在屏幕上显示所有内容,类似于 Spotify 的方式单击底部的横幅时执行此操作。有什么想法吗?

我真的想通了。我做了一个按钮并包含了这个代码来触发动画:

self.moveX.constant = 200;
[UIView animateWithDuration:2.0f animations:^{
    imageView.frame = CGRectMake(0.0f, 200.0f, imageView.frame.size.width,imageView.frame.size.height);
}];

如果你想要像这样的漂亮动画,我建议使用 spring 动画:

func buttonTapped(sender: UIButton!) { //or in an IBAction
    let duration: NSTimeInterval = 0.75
    let damping: CGFloat = 1
    let velocity: CGFloat = 0.5

    UIView.animateWithDuration(duration, delay: 0.5, usingSpringWithDamping: damping, initialSpringVelocity: velocity, options: .CurveLinear, animations: {
        self.myView.center.y = self.view.frame.height/2
        }, completion: nil)
}

抱歉 Swift 代码,如果您无法翻译它,请告诉我:)

编辑
对于 Objective-C,代码看起来像这样:

[UIView animateWithDuration:0.75, delay:0, usingSpringWithDamping:1, initialSpringVelocity:0.5, options:UIViewAnimationOptionsCurveLinear, animations:^{
    //Animations
  } completion:^(BOOL finished) {
    //Completion Block
}];