【发布时间】:2014-12-04 20:03:04
【问题描述】:
我正在开发一款遵循 Google 材料设计的应用。当我像 PageController 一样在屏幕上横向滑动时,我需要顶部图像(一种自定义 NavigationBar,不使用 NavigationController)淡入新图像,同时在该自定义顶部淡入和滑动新标题标签导航栏背景图片。
我可以使用此代码制作动画,但它是通过按下按钮或类似方式运行的,我怎样才能使其与手指滑动同步?
// Fade and slide title and image
myTitleLabelConstraint.constant = myTitleLabelConstraint.constant - 20;
[self.view setNeedsUpdateConstraints];
[UIView animateWithDuration:1.0 delay:0 usingSpringWithDamping:1.0 initialSpringVelocity:1.5 options:UIViewAnimationOptionTransitionNone animations:^{
// Animate
[self.view layoutIfNeeded];
myTitleLabel.alpha = 1;
topImageView.image = [UIImage imageNamed:@"blue_navBar.png"];
}completion:^(BOOL finished) {
// Complete
}];
我需要这种情况发生以及在 3 个 ViewControllers - 2 个 UIViewControllers 和 1 个 UITableViewController 之间滑动。我正在考虑使用托管 PageController 的容器 - 这是一个好的解决方案吗?
我看过 this 教程,但我发现很难理解他的实际意思。 Scrollview - 为什么要使用它?
所以我的问题总结如下:如何在带有或不带有 PageController 的 3 个 ViewControllers(带有 PageController至少物理)?
非常感谢您的帮助!
更新
这就是我的 StoryBoard 现在的样子:
仔细观察:
左侧的 ViewController 是包含 3 个容器的“主机”,而这三个容器中的每一个都链接到右侧的一个 ViewController。
最好的问候, 埃里克
【问题讨论】:
标签: ios objective-c animation uiview uigesturerecognizer